MCPcopy Create free account
hub / github.com/anjo76/angelscript / ParseVarInit

Method ParseVarInit

sdk/angelscript/source/as_parser.cpp:3747–3794  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3745}
3746
3747int asCParser::ParseVarInit(asCScriptCode *in_script, asCScriptNode *in_init)
3748{
3749 Reset();
3750
3751 // Tell the parser to validate the identifiers as valid types
3752 checkValidTypes = true;
3753
3754 this->script = in_script;
3755 sourcePos = in_init->tokenPos;
3756
3757 // If next token is assignment, parse expression
3758 sToken t;
3759 GetToken(&t);
3760 if( t.type == ttAssignment )
3761 {
3762 GetToken(&t);
3763 RewindTo(&t);
3764 if( t.type == ttStartStatementBlock )
3765 scriptNode = ParseInitList();
3766 else
3767 scriptNode = ParseAssignment();
3768 }
3769 else if( t.type == ttOpenParenthesis)
3770 {
3771 RewindTo(&t);
3772 scriptNode = ParseArgList();
3773 }
3774 else
3775 {
3776 int tokens[] = {ttAssignment, ttOpenParenthesis };
3777 Error(ExpectedOneOf(tokens, 2), &t);
3778 Error(InsteadFound(t), &t);
3779 }
3780
3781 // Don't allow any more tokens after the expression
3782 GetToken(&t);
3783 if( t.type != ttEnd && t.type != ttEndStatement && t.type != ttListSeparator && t.type != ttEndStatementBlock )
3784 {
3785 asCString msg;
3786 msg.Format(TXT_UNEXPECTED_TOKEN_s, asCTokenizer::GetDefinition(t.type));
3787 Error(msg, &t);
3788 }
3789
3790 if( isSyntaxError || errorWhileParsing )
3791 return -1;
3792
3793 return 0;
3794}
3795
3796asCScriptNode *asCParser::SuperficiallyParseVarInit()
3797{

Callers 2

CompileGlobalVariableMethod · 0.80

Calls 1

FormatMethod · 0.45

Tested by

no test coverage detected