Grammar NanoSqlLexer ANTLR-generated HTML file from /Users/donnie/Documents/CS122/Wi2017/nanodb-students/res/nanosql.g
Terence Parr, MageLang Institute
|
Definition of lexer NanoSqlLexer, which is a subclass of CharScanner. /** Lexer nextToken rule: * The lexer nextToken rule is synthesized from all of the user-defined * lexer rules. It logically consists of one big alternative block with * each user-defined rule being an alternative. */ mCOLON | mCOMMA | mLPAREN | mRPAREN | mSEMICOLON | mSTAR | mSLASH | mPERCENT | mPLUS | mMINUS | mNEWLINE | mWS | mCOMMENT | mCOMPARE_OPERATOR | mIDENT | mQUOTED_IDENT | mNUM_LITERAL_OR_SYMBOL | mSTRING_LITERAL mCOLON : ':' ; mCOMMA : ',' ; mLPAREN : '(' ; mRPAREN : ')' ; mSEMICOLON : ';' ; mSTAR : '*' ; mSLASH : '/' ; mPERCENT : '%' ; mPLUS : '+' ; mMINUS : '-' ; mNEWLINE : ( ( '\r' | ) '\n' ) ; mWS : ( ' ' | '\t' )+ ; /** * Comments - we skip those too. * * Note: No need to mention '\r' in this rule since it will match the wildcard * character that consumes characters up to the '\n'. */ mCOMMENT : ( '-' '-' ( . )* '\n' ) ; mCOMPARE_OPERATOR : '=' ( '=' | ) | '<' ( ( '>' ) | ( '=' ) | ) | '!' '=' | '>' ( '=' | ) ; mIDENT : ( 'A'..'Z' | 'a'..'z' | '_' ) ( 'A'..'Z' | 'a'..'z' | '0'..'9' | '_' )* ; mQUOTED_IDENT : '"' ( 'A'..'Z' | 'a'..'z' | '_' ) ( 'A'..'Z' | 'a'..'z' | '0'..'9' | '_' )* '"' ; /** * Number-literal parsing is tricky, because you might have an integer, a * decimal number, or a simple period ('.') by itself. This lexer rule handles * all three of these options, and sets the token-type appropriately. * <p> * Note that these numbers are <i>unsigned</i>. Signed numbers have to be * processed separately. */ mNUM_LITERAL_OR_SYMBOL : ( '0'..'9' )+ ( ( 'L' ) | ( '.' ( '0'..'9' )* ( ( 'f' | 'F' ) | ) ) | ) | '.' ( ( '0'..'9' ) ( '0'..'9' )* ( ( 'f' | 'F' ) | ) | ) ; mSTRING_LITERAL : '\'' ( ( '\'' | '\r' | '\n' ) )* '\'' ;