VapourSynth-llvmexpr
Loading...
Searching...
No Matches
infix2postfix::Parser Class Reference

#include <llvmexpr/frontend/infix2postfix/Parser.hpp>

Public Member Functions

 Parser (const std::vector< Token > &tokens)
ParseResult parse ()

Detailed Description

Definition at line 40 of file Parser.hpp.

Constructor & Destructor Documentation

◆ Parser()

infix2postfix::Parser::Parser ( const std::vector< Token > & tokens)
explicit

Definition at line 30 of file Parser.cpp.

30: tokens(tokens) {}

Member Function Documentation

◆ parse()

ParseResult infix2postfix::Parser::parse ( )

Definition at line 32 of file Parser.cpp.

32 {
33 auto program = std::make_unique<Program>();
34 while (!isAtEnd()) {
35 // Skip any leading empty statements
36 while (match({TokenType::Newline, TokenType::Semicolon})) {
37 }
38 if (isAtEnd()) {
39 break;
40 }
41
42 int pos_before = current;
43 auto stmt = parseDeclaration();
44 if (stmt) {
45 program->statements.push_back(std::move(stmt));
46 }
47 panic_mode = false;
48
49 if (current == pos_before && !isAtEnd() && !errors.empty()) {
50 advance();
51 }
52 }
53
54 return ParseResult{.ast = std::move(program), .errors = std::move(errors)};
55}

Referenced by infix2postfix::AnalysisEngine::runAnalysis().


The documentation for this class was generated from the following files: