Advertisement
Frumkin

Untitled

Aug 16th, 2021
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.71 KB | None | 0 0
  1. #include "Parser.hpp"
  2.  
  3. void Parser::Initialize() {
  4.     Diagnostics::Initialize(Tokenizer.Code);
  5. }
  6.  
  7. void Parser::CreateSyntaxTree() {
  8.     // representation of
  9.  
  10.     /*
  11.     function example(value: readonly integer, flag: readonly boolean) {
  12.  
  13.     }
  14.  
  15.     function main() {
  16.        
  17.     }
  18.     */
  19.  
  20.     program = Program(
  21.         {
  22.             GlobalFunction(
  23.                 "example",          // name
  24.                 {                   // parameters
  25.                     Parameter(
  26.                         "value",    // name
  27.                         true,       // is readonly
  28.                         "integer"   // typename
  29.                     ),
  30.                     Parameter(
  31.                         "flag",     // name
  32.                         true,       // is readonly
  33.                         "boolean"   // typename
  34.                     )
  35.                 },                  // end of parameter
  36.                 GlobalFunctionScope(
  37.                     false           // have't implemented yet
  38.                 )
  39.             ),
  40.             GlobalFunction(
  41.                 "main",             // name
  42.                 {},                 // no parameters
  43.                 GlobalFunctionScope(
  44.                     false           // haven't implemented yet
  45.                 )
  46.             )
  47.         }
  48.     );
  49. }
  50.  
  51. void Parser::Log() {
  52.     // you don't have to understand this. This is for the sake of representing everything with indents and pretty looking
  53.     std::vector<std::string> display = Diagnostics::Display(program);
  54.  
  55.     std::cout << "Program:" << std::endl;
  56.     for (std::size_t index = 0; index < display.size(); index += 1) {
  57.         std::cout << "  " << display[index] << std::endl;
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement