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

Method ParseParameterList

sdk/angelscript/source/as_parser.cpp:784–900  ·  view source on GitHub ↗

BNF:3: PARAMLIST ::= '(' ('void' | (TYPE TYPEMOD ('...' | IDENTIFIER? ('=' EXPR)?) (',' TYPE TYPEMOD ('...' | IDENTIFIER? ('=' EXPR)?))*))? ')'

Source from the content-addressed store, hash-verified

782
783// BNF:3: PARAMLIST ::= '(' ('void' | (TYPE TYPEMOD ('...' | IDENTIFIER? ('=' EXPR)?) (',' TYPE TYPEMOD ('...' | IDENTIFIER? ('=' EXPR)?))*))? ')'
784asCScriptNode *asCParser::ParseParameterList()
785{
786 asCScriptNode *node = CreateNode(snParameterList);
787 if( node == 0 ) return 0;
788
789 sToken t1;
790 GetToken(&t1);
791 if( t1.type != ttOpenParenthesis)
792 {
793 Error(ExpectedToken("("), &t1);
794 Error(InsteadFound(t1), &t1);
795 return node;
796 }
797
798 node->UpdateSourcePos(t1.pos, t1.length);
799
800 GetToken(&t1);
801 if( t1.type == ttCloseParenthesis )
802 {
803 node->UpdateSourcePos(t1.pos, t1.length);
804
805 // Statement block is finished
806 return node;
807 }
808 else
809 {
810 // If the parameter list is just (void) then the void token should be ignored
811 if( t1.type == ttVoid )
812 {
813 sToken t2;
814 GetToken(&t2);
815 if( t2.type == ttCloseParenthesis)
816 {
817 node->UpdateSourcePos(t2.pos, t2.length);
818 return node;
819 }
820 }
821
822 RewindTo(&t1);
823
824 for(;;)
825 {
826 // Parse data type
827 node->AddChildLast(ParseType(true, isParsingAppInterface));
828 if( isSyntaxError ) return node;
829
830 node->AddChildLast(ParseTypeMod(true));
831 if( isSyntaxError ) return node;
832
833 GetToken(&t1);
834
835 // Variadic
836 if (t1.type == ttVariadic)
837 {
838 node->AddChildLast(CreateNode(snVariadic));
839
840 sToken t2;
841 GetToken(&t2);

Callers

nothing calls this directly

Calls 2

UpdateSourcePosMethod · 0.80
AddChildLastMethod · 0.80

Tested by

no test coverage detected