C# Class Tup.Cobar4Net.Parser.Recognizer.Mysql.Lexer.MySqlLexer

support MySql 5.5 token
Exibir arquivo Open project: tupunco/Tup.Cobar4Net Class Usage Examples

Protected Properties

Property Type Description
ch char
curIndex int
eofIndex int
inCStyleComment bool
inCStyleCommentIgnore bool
offsetCache int
sbuf char[]
sbufRef ThreadLocal
sizeCache int
sql char[]

Public Methods

Method Description
AddCacheToke ( MySqlToken token ) : void
AppendStringContent ( StringBuilder sb ) : void

if GetStringValue returns "'abc\\'d'", then "abc\\'d" is appended

GetDecimalValue ( ) : BigDecimal
GetIntegerValue ( ) : Number

token must be MySqlToken.LiteralNumPureDigit

GetStringValue ( ) : string

make sense for those types of token:
MySqlToken.UsrVar : e.g. "@var1", "@'mary''s'";
MySqlToken.SysVar : e.g. "var2";
MySqlToken.LiteralChars , MySqlToken.LiteralNchars : e.g. "'ab\\'c'";
MySqlToken.LiteralBit : e.g. "0101"
MySqlToken.Identifier

GetStringValueUppercase ( ) : string

for MySqlToken.Identifier , MySqlToken.SysVar

MySqlLexer ( char sql ) : System
MySqlLexer ( string sql ) : System
NextToken ( ) : MySqlToken
SetCStyleCommentVersion ( int version ) : int
ToString ( ) : string
Token ( ) : MySqlToken

Protected Methods

Method Description
Eof ( ) : bool
Err ( string msg ) : SqlSyntaxErrorException

always throw SqlSyntaxErrorException

HasChars ( int howMany ) : bool
PutChar ( char ch, int index ) : void

Append a character to sbuf.

ScanBitField ( bool quoteMode ) : void
ScanChar ( ) : char
ScanChar ( int skip ) : char
ScanHexaDecimal ( bool quoteMode ) : void
ScanIdentifier ( ) : void

id is NOT included in `.

ScanIdentifierWithAccent ( ) : void

id is included in `.

id is included in `. first ` is included

ScanNumber ( ) : void

if first char is ., token may be MySqlToken.PuncDot if invalid char is presented after .

ScanPlaceHolder ( ) : void

not Sql syntax

ScanString ( ) : void
ScanSystemVariable ( ) : void

first @@ is included

ScanUserVariable ( ) : void

first @ is included

SkipSeparator ( ) : void

skip whitespace and comment

UpdateStringValue ( char src, int srcOffset, int len ) : void

update stringValue and stringValueUppercase . It is possible that sbuf be changed

Private Methods

Method Description
FromSQL2Chars ( string sql ) : char[]
NextTokenInternal ( ) : MySqlToken
ScanIdentifierFromNumber ( int initOffset, int initSize ) : void

NOTE: id dosn't include '.' for sake of performance issue (based on shaojin.wensj's design). However, it is not convenient for MySql compatibility. e.g. ".123f" will be regarded as ".123" and "f" in MySql, but in this MySqlLexer , it will be "." and "123f" because ".123f" may be part of "db1.123f" and "123f" is the table name.

Method Details

AddCacheToke() public method

public AddCacheToke ( MySqlToken token ) : void
token MySqlToken must be a keyword
return void

AppendStringContent() public method

if GetStringValue returns "'abc\\'d'", then "abc\\'d" is appended
public AppendStringContent ( StringBuilder sb ) : void
sb StringBuilder
return void

Eof() protected method

protected Eof ( ) : bool
return bool

Err() protected method

always throw SqlSyntaxErrorException
protected Err ( string msg ) : SqlSyntaxErrorException
msg string
return System.SqlSyntaxErrorException

GetDecimalValue() public method

public GetDecimalValue ( ) : BigDecimal
return BigDecimal

GetIntegerValue() public method

token must be MySqlToken.LiteralNumPureDigit
public GetIntegerValue ( ) : Number
return System.Number

GetStringValue() public method

make sense for those types of token:
MySqlToken.UsrVar : e.g. "@var1", "@'mary''s'";
MySqlToken.SysVar : e.g. "var2";
MySqlToken.LiteralChars , MySqlToken.LiteralNchars : e.g. "'ab\\'c'";
MySqlToken.LiteralBit : e.g. "0101"
MySqlToken.Identifier
public GetStringValue ( ) : string
return string

GetStringValueUppercase() public method

for MySqlToken.Identifier , MySqlToken.SysVar
public GetStringValueUppercase ( ) : string
return string

HasChars() protected method

protected HasChars ( int howMany ) : bool
howMany int
return bool

MySqlLexer() public method

public MySqlLexer ( char sql ) : System
sql char
return System

MySqlLexer() public method

public MySqlLexer ( string sql ) : System
sql string
return System

NextToken() public method

public NextToken ( ) : MySqlToken
return MySqlToken

PutChar() protected method

Append a character to sbuf.
protected PutChar ( char ch, int index ) : void
ch char
index int
return void

ScanBitField() protected method

protected ScanBitField ( bool quoteMode ) : void
quoteMode bool /// if false: first 0b has been skipped; if /// true: first b' has been skipped ///
return void

ScanChar() protected method

protected ScanChar ( ) : char
return char

ScanChar() protected method

protected ScanChar ( int skip ) : char
skip int /// if 1, then equals to /// ///
return char

ScanHexaDecimal() protected method

protected ScanHexaDecimal ( bool quoteMode ) : void
quoteMode bool /// if false: first 0x has been skipped; if /// true: first x' has been skipped ///
return void

ScanIdentifier() protected method

id is NOT included in `.
protected ScanIdentifier ( ) : void
return void

ScanIdentifierWithAccent() protected method

id is included in `.
id is included in `. first ` is included
protected ScanIdentifierWithAccent ( ) : void
return void

ScanNumber() protected method

if first char is ., token may be MySqlToken.PuncDot if invalid char is presented after .
protected ScanNumber ( ) : void
return void

ScanPlaceHolder() protected method

not Sql syntax
protected ScanPlaceHolder ( ) : void
return void

ScanString() protected method

protected ScanString ( ) : void
return void

ScanSystemVariable() protected method

first @@ is included
protected ScanSystemVariable ( ) : void
return void

ScanUserVariable() protected method

first @ is included
protected ScanUserVariable ( ) : void
return void

SetCStyleCommentVersion() public static method

public static SetCStyleCommentVersion ( int version ) : int
version int
return int

SkipSeparator() protected method

skip whitespace and comment
protected SkipSeparator ( ) : void
return void

ToString() public method

public ToString ( ) : string
return string

Token() public method

public Token ( ) : MySqlToken
return MySqlToken

UpdateStringValue() protected method

update stringValue and stringValueUppercase . It is possible that sbuf be changed
protected UpdateStringValue ( char src, int srcOffset, int len ) : void
src char
srcOffset int
len int
return void

Property Details

ch protected_oe property

always be sql [ curIndex ]
protected char ch
return char

curIndex protected_oe property

current index of sql
protected int curIndex
return int

eofIndex protected_oe property

always be sql .length - 1
protected int eofIndex
return int

inCStyleComment protected_oe property

protected bool inCStyleComment
return bool

inCStyleCommentIgnore protected_oe property

protected bool inCStyleCommentIgnore
return bool

offsetCache protected_oe property

protected int offsetCache
return int

sbuf protected_oe property

protected char[] sbuf
return char[]

sbufRef protected_oe static_oe property

A character buffer for literals.
protected static ThreadLocal sbufRef
return ThreadLocal

sizeCache protected_oe property

protected int sizeCache
return int

sql protected_oe property

protected char[] sql
return char[]