src/parser.cpp

changeset 141
68d60e2cfa76
parent 139
cf11621ae422
equal deleted inserted replaced
140:04a6eb68f226 141:68d60e2cfa76
200 200
201 // If nothing else, parse it as a statement 201 // If nothing else, parse it as a statement
202 m_lexer->skip (-1); 202 m_lexer->skip (-1);
203 DataBuffer* b = parseStatement(); 203 DataBuffer* b = parseStatement();
204 204
205 if (b == false) 205 if (b == null)
206 { 206 {
207 m_lexer->next(); 207 m_lexer->next();
208 error ("unknown token `%1`", getTokenString()); 208 error ("unknown token `%1`", getTokenString());
209 } 209 }
210 210
863 comm->origin = m_lexer->describeCurrentPosition(); 863 comm->origin = m_lexer->describeCurrentPosition();
864 864
865 // Return value 865 // Return value
866 m_lexer->mustGetAnyOf ({Token::Int,Token::Void,Token::Bool,Token::Str}); 866 m_lexer->mustGetAnyOf ({Token::Int,Token::Void,Token::Bool,Token::Str});
867 comm->returnvalue = getTypeByName (m_lexer->token()->text); // TODO 867 comm->returnvalue = getTypeByName (m_lexer->token()->text); // TODO
868 ASSERT_NE (comm->returnvalue, -1); 868 ASSERT_NE (comm->returnvalue, TYPE_Unknown);
869 869
870 // Number 870 // Number
871 m_lexer->mustGetNext (Token::Number); 871 m_lexer->mustGetNext (Token::Number);
872 comm->number = m_lexer->token()->text.toLong(); 872 comm->number = m_lexer->token()->text.toLong();
873 m_lexer->mustGetNext (Token::Colon); 873 m_lexer->mustGetNext (Token::Colon);
886 m_lexer->mustGetNext (Token::Comma); 886 m_lexer->mustGetNext (Token::Comma);
887 887
888 CommandArgument arg; 888 CommandArgument arg;
889 m_lexer->mustGetAnyOf ({Token::Int,Token::Bool,Token::Str}); 889 m_lexer->mustGetAnyOf ({Token::Int,Token::Bool,Token::Str});
890 DataType type = getTypeByName (m_lexer->token()->text); // TODO 890 DataType type = getTypeByName (m_lexer->token()->text); // TODO
891 ASSERT_NE (type, -1) 891 ASSERT_NE (type, TYPE_Unknown)
892 ASSERT_NE (type, TYPE_Void) 892 ASSERT_NE (type, TYPE_Void)
893 arg.type = type; 893 arg.type = type;
894 894
895 m_lexer->mustGetNext (Token::Symbol); 895 m_lexer->mustGetNext (Token::Symbol);
896 arg.name = m_lexer->token()->text; 896 arg.name = m_lexer->token()->text;

mercurial