From 900fb0aee0b68cbb88f578f20019738b4416f436 Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Mon, 4 Nov 2019 10:27:29 +0100 Subject: Add query language interpreter code --- .../edu/mimuw/cloudatlas/interpreter/query/Yylex | 76 ++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Yylex (limited to 'src/main/java/pl/edu/mimuw/cloudatlas/interpreter/query/Yylex') 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 +%% +; { return new Symbol(sym._SYMB_0); } +, { return new Symbol(sym._SYMB_1); } +\+ { return new Symbol(sym._SYMB_2); } +- { return new Symbol(sym._SYMB_3); } +\* { return new Symbol(sym._SYMB_4); } +/ { return new Symbol(sym._SYMB_5); } +% { return new Symbol(sym._SYMB_6); } +\( { return new Symbol(sym._SYMB_7); } +\) { return new Symbol(sym._SYMB_8); } +> { return new Symbol(sym._SYMB_9); } += { return new Symbol(sym._SYMB_10); } +<> { return new Symbol(sym._SYMB_11); } +< { return new Symbol(sym._SYMB_12); } +<= { return new Symbol(sym._SYMB_13); } +>= { return new Symbol(sym._SYMB_14); } +AND { return new Symbol(sym._SYMB_15); } +AS { return new Symbol(sym._SYMB_16); } +ASC { return new Symbol(sym._SYMB_17); } +BY { return new Symbol(sym._SYMB_18); } +DESC { return new Symbol(sym._SYMB_19); } +FIRST { return new Symbol(sym._SYMB_20); } +LAST { return new Symbol(sym._SYMB_21); } +NOT { return new Symbol(sym._SYMB_22); } +NULLS { return new Symbol(sym._SYMB_23); } +OR { return new Symbol(sym._SYMB_24); } +ORDER { return new Symbol(sym._SYMB_25); } +REGEXP { return new Symbol(sym._SYMB_26); } +SELECT { return new Symbol(sym._SYMB_27); } +WHERE { return new Symbol(sym._SYMB_28); } + +true|false { return new Symbol(sym.QBool, yytext().intern()); } +({LETTER}|&)({LETTER}|{DIGIT}|_)* { return new Symbol(sym.QIdent, yytext().intern()); } +{DIGIT}*\.{DIGIT}+([eE]-?{DIGIT}+)?|{DIGIT}+([eE]-?{DIGIT}+) { return new Symbol(sym.QDouble, yytext().intern()); } +0|[123456789]{DIGIT}* { return new Symbol(sym.QInteger, yytext().intern()); } + +"\"" { yybegin(STRING); } +\\ { yybegin(ESCAPED); } +\" { String foo = pstring; pstring = new String(); yybegin(YYINITIAL); return new Symbol(sym._STRING_, foo.intern()); } +. { pstring += yytext(); } +n { pstring += "\n"; yybegin(STRING); } +\" { pstring += "\""; yybegin(STRING); } +\\ { pstring += "\\"; yybegin(STRING); } +t { pstring += "\t"; yybegin(STRING); } +. { pstring += yytext(); yybegin(STRING); } + + + + + +[ \t\r\n\f] { /* ignore white space. */ } -- cgit v1.2.3