Translations:Development/KDevelop-PG-Qt Introduction/199/en
Inside your actions of the lexer you can use some predefined macros:
lxCURR_POS // position in the input (some kind of iterator or pointer) lxCURR_IDX // index of the position in the input // (it is the index as presented in the input, for example: input is a QByteArray, index incrementation per byte, but the lexer may operate on 32-bit codepoints) lxCONTINUE // like %continue, add the current lexeme to the next token lxLENGTH // length of the current lexeme (as presented in the input) lxBEGIN_POS // position of the first character of the current lexeme lxBEGIN_IDX // corresponding index lxNAMED_TOKEN(⟨name⟩, ⟨type⟩) // create a variable representing named ⟨name⟩ with the token type ⟨type⟩ lxTOKEN(⟨type⟩) // create such a variable named “token” lxDONE // return the token generated before lxRETURN(X) // create a token of type X and return it lxEOF // create the EOF-token lxFINISH // create the EOF-token and return it (will stop tokenization) lxFAIL // raise the tokenization error lxSKIP // continue with the next lexeme (do not return a token, you should not have created one before) lxNEXT_CHR(⟨chr⟩) // set the variable ⟨chr⟩ to the next char in the input yytoken // current token