C# 클래스 _3PA.MainFeatures.Parser.Lexer

This class "tokenize" the input data into tokens of various types, it implements a visitor pattern
파일 보기 프로젝트 열기: jcaillon/3P 1 사용 예제들

공개 메소드들

메소드 설명
Accept ( ILexerVisitor visitor ) : void

Feed this method with a visitor implementing ILexerVisitor to visit all the tokens of the input string (you must call the Tokenize() methode before that!)

Lexer ( string data ) : System

constructor, data is the input string to tokenize call Tokenize() to do the work

Lexer ( string data, int pos, int line, int column, int commentDepth, int includeDepth ) : System

Use this when you wish to tokenize only a partial string in a longer string Allows you to start with a comment depth different of 0

MoveNextToken ( ) : bool

To use this lexer as an enumerator, Move to the next token, return true if it can

PeekAtToken ( int x ) : Token

To use this lexer as an enumerator, peek at the current pos + x token of the list, returns a new TokenEof if can't find

비공개 메소드들

메소드 설명
CreateCommentToken ( ) : Token

create a comment token, take into account nested comment, reads until all comments tags are closed

CreateEolToken ( char ch ) : Token
CreateEosToken ( ) : Token
CreateIncludeToken ( ) : Token

reads an include declaration

CreateNumberToken ( ) : Token

create a number token, accepts decimal value with a '.' and hexadecimal notation 0xNNN

CreatePreProcessedStatement ( ) : Token

reads a preproc definition

CreateSingleLineCommentToken ( ) : Token

create a comment token, for a single line comment

CreateStringDescriptorToken ( ) : Token

A character-string in progress can be described with different properties : "characters" [ : [ R | L | C | T ] [ U ] [ max-length ] ]

CreateStringToken ( char strChar ) : Token

reads a quotes string (either simple of double quote), takes into account escape char ~

CreateSymbolToken ( ) : Token
CreateWhitespaceToken ( ) : Token

create a whitespace token (successions of either ' ' or '\t')

GetNext ( ) : Token

returns the next token of the string

GetTokenValue ( ) : string

Returns the current value of the token

PeekAt ( int x ) : char

Peek forward x chars

PeekAtReverse ( int x ) : char

peek backward x chars

Read ( ) : void

Read to the next char, indirectly adding the current char (_data[_pos]) to the current token

ReadEol ( char eol = '\n' ) : void

Read the End Of Line character (can read \r\n in one go), add it to the current token

ReadWord ( ) : void

reads a word with this format : [a-Z_&]+[\w_-]*((\.[\w_-]*)?){1,}

Tokenize ( ) : void

Call this method to actually tokenize the string

메소드 상세

Accept() 공개 메소드

Feed this method with a visitor implementing ILexerVisitor to visit all the tokens of the input string (you must call the Tokenize() methode before that!)
public Accept ( ILexerVisitor visitor ) : void
visitor ILexerVisitor
리턴 void

Lexer() 공개 메소드

constructor, data is the input string to tokenize call Tokenize() to do the work
public Lexer ( string data ) : System
data string
리턴 System

Lexer() 공개 메소드

Use this when you wish to tokenize only a partial string in a longer string Allows you to start with a comment depth different of 0
public Lexer ( string data, int pos, int line, int column, int commentDepth, int includeDepth ) : System
data string
pos int
line int
column int
commentDepth int
includeDepth int
리턴 System

MoveNextToken() 공개 메소드

To use this lexer as an enumerator, Move to the next token, return true if it can
public MoveNextToken ( ) : bool
리턴 bool

PeekAtToken() 공개 메소드

To use this lexer as an enumerator, peek at the current pos + x token of the list, returns a new TokenEof if can't find
public PeekAtToken ( int x ) : Token
x int
리턴 Token