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

Method ParseConstant

sdk/angelscript/source/as_parser.cpp:1722–1752  ·  view source on GitHub ↗

BNF:12: LITERAL ::= NUMBER | STRING | BITS | 'true' | 'false' | 'null' BNF:17: NUMBER ::= [0-9]+("."[0-9]+)? // single token: includes integers and real numbers, same as C++ BNF:17: STRING ::= '"' ("\". | [^"#x0D#x0A\\])* '"' // single token: single quoted ', double quoted ", or heredoc multi-line string """ BNF:17: BITS ::= '0'[bBoOdDxX][0-9A-Fa-f]+

Source from the content-addressed store, hash-verified

1720// BNF:17: STRING ::= '"' ("\". | [^"#x0D#x0A\\])* '"' // single token: single quoted ', double quoted ", or heredoc multi-line string """
1721// BNF:17: BITS ::= '0'[bBoOdDxX][0-9A-Fa-f]+ // single token: binary 0b or 0B, octal 0o or 0O, decimal 0d or 0D, hexadecimal 0x or 0X
1722asCScriptNode *asCParser::ParseConstant()
1723{
1724 asCScriptNode *node = CreateNode(snConstant);
1725 if( node == 0 ) return 0;
1726
1727 sToken t;
1728 GetToken(&t);
1729 if( !IsConstant(t.type) )
1730 {
1731 Error(TXT_EXPECTED_CONSTANT, &t);
1732 Error(InsteadFound(t), &t);
1733 return node;
1734 }
1735
1736 node->SetToken(&t);
1737 node->UpdateSourcePos(t.pos, t.length);
1738
1739 // We want to gather a list of string constants to concatenate as children
1740 if( t.type == ttStringConstant || t.type == ttMultilineStringConstant || t.type == ttHeredocStringConstant )
1741 RewindTo(&t);
1742
1743 while( t.type == ttStringConstant || t.type == ttMultilineStringConstant || t.type == ttHeredocStringConstant )
1744 {
1745 node->AddChildLast(ParseStringConstant());
1746
1747 GetToken(&t);
1748 RewindTo(&t);
1749 }
1750
1751 return node;
1752}
1753
1754bool asCParser::IsLambda()
1755{

Callers

nothing calls this directly

Calls 3

SetTokenMethod · 0.80
UpdateSourcePosMethod · 0.80
AddChildLastMethod · 0.80

Tested by

no test coverage detected