2.2 KiB
2.2 KiB
AGPascalTokenizer
Tokenizer Library for Delphi/FPC. Based on PyPascalTokenizer work by Artem Gavrilov.
API
TAGToken struct
TAGToken is a record type of:
- Text:
stringwith token text. - &begin:
TAGTokenizerPoswith start position of token. - &end:
TAGTokenizerPoswith end position of token. - ended:
booleanflag, true if it was the last token.
Has Create constructor with all values.
TAGTokenizerPos
record, saves position of token if format:
- x:
integerplatform-depend-base (NEXTGEN) character index in line. - y:
integer0-based line index.
Class TAGPasTokenizer
Main class of tokenizer.
- get_next():
TAGTokenfunction, returns. Get next token and change pos - pos:
TAGTokenizerPosproperty, containing position whear tokenizer was stoped after last get_next(), writeble. - is_ended:
booleanproperty, check if text ended.
Has constructor Create with input: TStrings param.
Class TAGPasTokenizerStack
Stack of tokens automaticaly filled from input.
- Push(t:
TAGToken) push token to stack. - Pop():
TAGTokenpop token from stack. - Last:
TAGTokenproperty, seek stask head. - ended:
booleanproperty, check if text ended.
Has constructor Create with input: TStrings and GetComments: boolean=True param.
Class TAGPasTokenizerParallelStack
Stack of tokens automaticaly filled from input(in second tread).
- Push(t:
TAGToken) push token to stack. - Pop():
TAGTokenpop token from stack. - Last:
TAGTokenproperty, seek stask head. - ended:
booleanproperty, check if text ended.
Has constructor Create with input: TStrings, GetComments: boolean=True and stackMax:integer=1000 param.
Utils
Helper functions to analyze token text.
- IsName(s:
string):booleanCheck for valid identifier (can be reserved word too). - IsComment(s:
string):booleanCheck for valid comment. - IsString(s:
string):booleanCheck for string constant.