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

Method GetToken

sdk/angelscript/source/as_parser.cpp:1006–1043  ·  view source on GitHub ↗

BNF:18: COMMENT ::= ('//'[^#x0A]*) | ('/*'[^*]*'*/') // single token: starts with // and ends with new line or starts with /* and ends with */ BNF:18: WHITESPACE ::= [ #x09#x0A#x0D]+ // single token: spaces, tab, carriage return, line feed, and UTF8 byte-order-mark

Source from the content-addressed store, hash-verified

1004// BNF:18: COMMENT ::= ('//'[^#x0A]*) | ('/*'[^*]*'*/') // single token: starts with // and ends with new line or starts with /* and ends with */
1005// BNF:18: WHITESPACE ::= [ #x09#x0A#x0D]+ // single token: spaces, tab, carriage return, line feed, and UTF8 byte-order-mark
1006void asCParser::GetToken(sToken *token)
1007{
1008 // Check if the token has already been parsed
1009 if( lastToken.pos == sourcePos )
1010 {
1011 *token = lastToken;
1012 sourcePos += token->length;
1013
1014 if( token->type == ttWhiteSpace ||
1015 token->type == ttOnelineComment ||
1016 token->type == ttMultilineComment )
1017 GetToken(token);
1018
1019 return;
1020 }
1021
1022 // Parse new token
1023 size_t sourceLength = script->codeLength;
1024 do
1025 {
1026 if( sourcePos >= sourceLength )
1027 {
1028 token->type = ttEnd;
1029 token->length = 0;
1030 }
1031 else
1032 token->type = engine->tok.GetToken(&script->code[sourcePos], sourceLength - sourcePos, &token->length);
1033
1034 token->pos = sourcePos;
1035
1036 // Update state
1037 sourcePos += token->length;
1038 }
1039 // Filter out whitespace and comments
1040 while( token->type == ttWhiteSpace ||
1041 token->type == ttOnelineComment ||
1042 token->type == ttMultilineComment );
1043}
1044
1045void asCParser::SetPos(size_t pos)
1046{

Callers 6

ParseNamespaceMethod · 0.45
ParseTokenMethod · 0.45
RegisterInterfaceMethod · 0.45
RegisterTypedefMethod · 0.45
RegisterEnumMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected