TorqueScript  0.2
astbuilder.hpp
1 
15 #pragma once
16 
17 #include <memory>
18 
19 #include "antlr4-runtime.h"
20 #include <TorqueBaseVisitor.h>
21 
22 #include <torquescript/codeblock.hpp>
23 #include <torquescript/stringtable.hpp>
24 #include <torquescript/instructions.hpp>
25 #include <torquescript/ast.hpp>
26 #include <torquescript/instructionsequence.hpp>
27 
28 namespace TorqueScript
29 {
30  typedef std::vector<InstructionSequence> GeneratedInstructions;
31 
32  namespace AST
33  {
34  class ASTBuilder : public TorqueBaseVisitor
35  {
36  public:
37  ASTBuilder(StringTable* stringTable);
38 
39  virtual antlrcpp::Any defaultResult() override;
40 
41  virtual antlrcpp::Any visitChildren(antlr4::tree::ParseTree *node) override;
42 
43  virtual antlrcpp::Any visitProgram(TorqueParser::ProgramContext* context) override;
44  virtual antlrcpp::Any visitPackage_declaration(TorqueParser::Package_declarationContext* context) override;
45  virtual antlrcpp::Any visitFunction_declaration(TorqueParser::Function_declarationContext* context) override;
46  virtual antlrcpp::Any visitCall(TorqueParser::CallContext* context) override;
47  virtual antlrcpp::Any visitSubcall(TorqueParser::SubcallContext* context) override;
48  virtual antlrcpp::Any visitValue(TorqueParser::ValueContext* context) override;
49  virtual antlrcpp::Any visitArithmetic(TorqueParser::ArithmeticContext* context) override;
50  virtual antlrcpp::Any visitAssign(TorqueParser::AssignContext* context) override;
51  virtual antlrcpp::Any visitUnary(TorqueParser::UnaryContext* context) override;
52  virtual antlrcpp::Any visitWhile_control(TorqueParser::While_controlContext* context) override;
53  virtual antlrcpp::Any visitIf_control(TorqueParser::If_controlContext* context) override;
54  virtual antlrcpp::Any visitFor_control(TorqueParser::For_controlContext* context) override;
55  virtual antlrcpp::Any visitLocalvariable(TorqueParser::LocalvariableContext* context) override;
56  virtual antlrcpp::Any visitGlobalvariable(TorqueParser::GlobalvariableContext* context) override;
57  virtual antlrcpp::Any visitIncrement(TorqueParser::IncrementContext* context) override;
58  virtual antlrcpp::Any visitReturn_control(TorqueParser::Return_controlContext* context) override;
59  virtual antlrcpp::Any visitEquality(TorqueParser::EqualityContext* context) override;
60  virtual antlrcpp::Any visitConcat(TorqueParser::ConcatContext* context) override;
61  virtual antlrcpp::Any visitTernary(TorqueParser::TernaryContext* context) override;
62  virtual antlrcpp::Any visitSubfield(TorqueParser::SubfieldContext* context) override;
63  virtual antlrcpp::Any visitArray(TorqueParser::ArrayContext* context) override;
64  virtual antlrcpp::Any visitRelational(TorqueParser::RelationalContext* context) override;
65  virtual antlrcpp::Any visitSwitch_control(TorqueParser::Switch_controlContext* context) override;
66  virtual antlrcpp::Any visitSubarray(TorqueParser::SubarrayContext* context) override;
67 
68  virtual antlrcpp::Any visitField_assign(TorqueParser::Field_assignContext* context) override;
69  virtual antlrcpp::Any visitDatablock_declaration(TorqueParser::Datablock_declarationContext* context) override;
70  virtual antlrcpp::Any visitObject_declaration(TorqueParser::Object_declarationContext* context) override;
71 
72  private:
73  StringTable* mStringTable;
74  };
75  }
76 }
Definition: astbuilder.hpp:35
A string table maintains a mapping of numeric identifiers to their raw string values....
Definition: stringtable.hpp:32
Definition: ast.hpp:28