diff options
author | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2019-11-04 10:27:29 +0100 |
---|---|---|
committer | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2019-11-04 10:27:29 +0100 |
commit | 900fb0aee0b68cbb88f578f20019738b4416f436 (patch) | |
tree | 9ac25ac14f2b8eaac7bbd152e4ae567de6b63e16 /src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Yylex | |
parent | 362310157373eef80f49ea6023b1666b3883f4b1 (diff) |
Add query language interpreter code
Diffstat (limited to 'src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Yylex')
-rw-r--r-- | src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Yylex | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Yylex b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Yylex new file mode 100644 index 0000000..4dd8029 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Yylex @@ -0,0 +1,76 @@ +// This JLex file was machine-generated by the BNF converter +package pl.edu.mimuw.mmws.cloudatlas.query; + +import java_cup.runtime.*; +%% +%cup +%unicode +%line +%public +%{ + String pstring = new String(); + public int line_num() { return (yyline+1); } + public String buff() { return new String(yy_buffer,yy_buffer_index,10).trim(); } +%} +LETTER = ({CAPITAL}|{SMALL}) +CAPITAL = [A-Z\xC0-\xD6\xD8-\xDE] +SMALL = [a-z\xDF-\xF6\xF8-\xFF] +DIGIT = [0-9] +IDENT = ({LETTER}|{DIGIT}|['_]) +%state COMMENT +%state CHAR +%state CHARESC +%state CHAREND +%state STRING +%state ESCAPED +%% +<YYINITIAL>; { return new Symbol(sym._SYMB_0); } +<YYINITIAL>, { return new Symbol(sym._SYMB_1); } +<YYINITIAL>\+ { return new Symbol(sym._SYMB_2); } +<YYINITIAL>- { return new Symbol(sym._SYMB_3); } +<YYINITIAL>\* { return new Symbol(sym._SYMB_4); } +<YYINITIAL>/ { return new Symbol(sym._SYMB_5); } +<YYINITIAL>% { return new Symbol(sym._SYMB_6); } +<YYINITIAL>\( { return new Symbol(sym._SYMB_7); } +<YYINITIAL>\) { return new Symbol(sym._SYMB_8); } +<YYINITIAL>> { return new Symbol(sym._SYMB_9); } +<YYINITIAL>= { return new Symbol(sym._SYMB_10); } +<YYINITIAL><> { return new Symbol(sym._SYMB_11); } +<YYINITIAL>< { return new Symbol(sym._SYMB_12); } +<YYINITIAL><= { return new Symbol(sym._SYMB_13); } +<YYINITIAL>>= { return new Symbol(sym._SYMB_14); } +<YYINITIAL>AND { return new Symbol(sym._SYMB_15); } +<YYINITIAL>AS { return new Symbol(sym._SYMB_16); } +<YYINITIAL>ASC { return new Symbol(sym._SYMB_17); } +<YYINITIAL>BY { return new Symbol(sym._SYMB_18); } +<YYINITIAL>DESC { return new Symbol(sym._SYMB_19); } +<YYINITIAL>FIRST { return new Symbol(sym._SYMB_20); } +<YYINITIAL>LAST { return new Symbol(sym._SYMB_21); } +<YYINITIAL>NOT { return new Symbol(sym._SYMB_22); } +<YYINITIAL>NULLS { return new Symbol(sym._SYMB_23); } +<YYINITIAL>OR { return new Symbol(sym._SYMB_24); } +<YYINITIAL>ORDER { return new Symbol(sym._SYMB_25); } +<YYINITIAL>REGEXP { return new Symbol(sym._SYMB_26); } +<YYINITIAL>SELECT { return new Symbol(sym._SYMB_27); } +<YYINITIAL>WHERE { return new Symbol(sym._SYMB_28); } + +<YYINITIAL>true|false { return new Symbol(sym.QBool, yytext().intern()); } +<YYINITIAL>({LETTER}|&)({LETTER}|{DIGIT}|_)* { return new Symbol(sym.QIdent, yytext().intern()); } +<YYINITIAL>{DIGIT}*\.{DIGIT}+([eE]-?{DIGIT}+)?|{DIGIT}+([eE]-?{DIGIT}+) { return new Symbol(sym.QDouble, yytext().intern()); } +<YYINITIAL>0|[123456789]{DIGIT}* { return new Symbol(sym.QInteger, yytext().intern()); } + +<YYINITIAL>"\"" { yybegin(STRING); } +<STRING>\\ { yybegin(ESCAPED); } +<STRING>\" { String foo = pstring; pstring = new String(); yybegin(YYINITIAL); return new Symbol(sym._STRING_, foo.intern()); } +<STRING>. { pstring += yytext(); } +<ESCAPED>n { pstring += "\n"; yybegin(STRING); } +<ESCAPED>\" { pstring += "\""; yybegin(STRING); } +<ESCAPED>\\ { pstring += "\\"; yybegin(STRING); } +<ESCAPED>t { pstring += "\t"; yybegin(STRING); } +<ESCAPED>. { pstring += yytext(); yybegin(STRING); } + + + + + +<YYINITIAL>[ \t\r\n\f] { /* ignore white space. */ } |