Skip to content

Syntax Parser Extension

Jaysmito Mukherjee edited this page Nov 8, 2021 · 3 revisions

Include

#include "lexpp.h"
#include "extensions/syntax_parser.h"

Creating a Parser

std::shared_ptr<lexpp::SyntaxParser> parser = std::make_shared<lexpp::SyntaxParser>(data);

Parsing the data

lexpp::lex(parser);

Displaying the Result

std::cout << std::setfill(' ') << std::left;
std::cout << std::setw(30) << "Token" << std::setw(30) << "Type" << std::endl;
for(lexpp::SyntaxToken& token : parser->get_tokens())
{
    std::cout << std::setw(30) << token.value << std::setw(30) << lexpp::to_string(token.type) << std::endl;
}    
Clone this wiki locally