src/script/parser.cpp

branch
scripting
changeset 924
d1ac217c9165
parent 923
e15a577a0bfe
child 925
2f316b57b508
equal deleted inserted replaced
923:e15a577a0bfe 924:d1ac217c9165
87 // 87 //
88 void Script::Parser::parse() 88 void Script::Parser::parse()
89 { 89 {
90 preprocess(); 90 preprocess();
91 m_state.reset(); 91 m_state.reset();
92 92 m_astRoot = Ast::spawnRoot();
93 while (next (TOK_Any)) 93
94 { 94 while (next())
95 print ("token: %1 (%2)\n", state().token.text, TokenNames[state().token.type]); 95 {
96 } 96 if (m_state.token.type == TOK_Semicolon)
97 continue;
98
99 tokenMustBe (TOK_Macro);
100 mustGetNext (TOK_Symbol);
101 Ast::MacroPointer macroAst = Ast::spawn<Ast::MacroNode> (m_astRoot, state().token.text);
102 mustGetNext (TOK_Semicolon);
103
104 do
105 {
106 mustGetNext();
107 } while (m_state.token.type != TOK_EndMacro);
108 }
109
110 m_astRoot->dump();
97 } 111 }
98 112
99 // 113 //
100 // ------------------------------------------------------------------------------------------------- 114 // -------------------------------------------------------------------------------------------------
101 // 115 //
570 } 584 }
571 585
572 unread(); 586 unread();
573 return identifier; 587 return identifier;
574 } 588 }
589
590 //
591 // -------------------------------------------------------------------------------------------------
592 //
593 void Script::Parser::tokenMustBe (TokenType desiredType)
594 {
595 if (m_state.token.type != desiredType)
596 {
597 scriptError ("expected %1, got %2",
598 TokenNames[desiredType],
599 TokenNames[m_state.token.type]);
600 }
601 }

mercurial