Skip to content
Snippets Groups Projects
Commit 1e93f62a authored by Tony Zhang's avatar Tony Zhang
Browse files

Fix bug caused by yytext

parent 3d0239bf
No related branches found
No related tags found
1 merge request!7Rewrite Parsers for SQLP Query, Schema, and Referring Type Expression
...@@ -200,55 +200,55 @@ AttrPath ...@@ -200,55 +200,55 @@ AttrPath
VarIdentifier VarIdentifier
: IDENTIFIER : IDENTIFIER
{ {
printf("VarIdentifier is |%s| ", yytext); printf("VarIdentifier is |%s| ", identifier);
$$ = create_var(yytext); $$ = create_var(identifier);
} }
TableIdentifier TableIdentifier
: IDENTIFIER : IDENTIFIER
{ {
printf("TableIdentifier is |%s| ", yytext); printf("TableIdentifier is |%s| ", identifier);
$$ = create_var(yytext); $$ = create_var(identifier);
} }
AttrIdentifier AttrIdentifier
: IDENTIFIER : IDENTIFIER
{ {
printf("AttrIdentifier is |%s| ", yytext); printf("AttrIdentifier is |%s| ", identifier);
$$ = create_var(yytext); $$ = create_var(identifier);
} }
CompOperator CompOperator
: EQ : EQ
{ {
printf("CompOperator EQ\n"); printf("CompOperator EQ\n");
$$ = create_op(yytext); $$ = create_op("=");
} }
| NE | NE
{ {
printf("CompOperator NE\n"); printf("CompOperator NE\n");
$$ = create_op(yytext); $$ = create_op("<>");
} }
| LE | LE
{ {
printf("CompOperator LE\n"); printf("CompOperator LE\n");
$$ = create_op(yytext); $$ = create_op("<=");
} }
| GE | GE
{ {
printf("CompOperator GE\n"); printf("CompOperator GE\n");
$$ = create_op(yytext); $$ = create_op(">=");
} }
| LT | LT
{ {
printf("CompOperator LT\n"); printf("CompOperator LT\n");
$$ = create_op(yytext); $$ = create_op("<");
} }
| GT | GT
{ {
printf("CompOperator GT\n"); printf("CompOperator GT\n");
$$ = create_op(yytext); $$ = create_op(">");
} }
; ;
...@@ -317,25 +317,25 @@ Term ...@@ -317,25 +317,25 @@ Term
Integer Integer
: INTEGER : INTEGER
{ {
printf("INTEGER is |%s|", yytext); printf("INTEGER is |%s|", constant);
$$ = create_constant(yytext); $$ = create_constant(constant);
} }
Constant Constant
: INTEGER : INTEGER
{ {
printf("INTEGER is |%s|", yytext); printf("INTEGER is |%s|", constant);
$$ = create_constant(yytext); $$ = create_constant(constant);
} }
| REAL | REAL
{ {
printf("REAL is |%s|", yytext); printf("REAL is |%s|", constant);
$$ = create_constant(yytext); $$ = create_constant(constant);
} }
| STRING | STRING
{ {
printf("STRING is |%s|", yytext); printf("STRING is |%s|", constant);
$$ = create_constant(yytext); $$ = create_constant(constant);
} }
; ;
...@@ -34,7 +34,7 @@ SQLPRefExp ...@@ -34,7 +34,7 @@ SQLPRefExp
; ;
OidExpLst OidExpLst
: OidExpLst ';' OidExp : OidExpLst ';' OidExp
{ {
printf("OidExpLst\n"); printf("OidExpLst\n");
$$ = create_oidexplst_operator($1, $3); $$ = create_oidexplst_operator($1, $3);
...@@ -86,12 +86,12 @@ Col ...@@ -86,12 +86,12 @@ Col
AttrPath AttrPath
: AttrIdentifier : AttrIdentifier
{ {
printf("path id\n"); printf("path id\n");
$$ = create_pf($1, NULL); $$ = create_pf($1, NULL);
} }
| AttrIdentifier '.' AttrPath | AttrIdentifier '.' AttrPath
{ {
printf("Path Function\n"); printf("Path Function\n");
$$ = create_pf($1, $3); $$ = create_pf($1, $3);
} }
...@@ -100,21 +100,20 @@ AttrPath ...@@ -100,21 +100,20 @@ AttrPath
VarIdentifier VarIdentifier
: IDENTIFIER : IDENTIFIER
{ {
printf("|%s| ", yytext); printf("|%s| ", identifier);
$$ = create_var(yytext); $$ = create_var(identifier);
} }
TableIdentifier TableIdentifier
: IDENTIFIER : IDENTIFIER
{ {
printf("|%s| ", yytext); printf("|%s| ", identifier);
$$ = create_table(yytext); $$ = create_table(identifier);
} }
AttrIdentifier AttrIdentifier
: IDENTIFIER : IDENTIFIER
{ {
printf("|%s| ", yytext); printf("|%s| ", identifier);
$$ = create_attr(yytext); $$ = create_attr(identifier);
} }
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
int LineNumber = 1; int LineNumber = 1;
char LineBuffer[200]; char LineBuffer[200];
char identifier[200];
char constant[200];
%} %}
%p 3000 %p 3000
...@@ -121,14 +123,14 @@ E [Ee][+-]?{D}+ ...@@ -121,14 +123,14 @@ E [Ee][+-]?{D}+
"with" { strcat(LineBuffer, yytext); return(WITH); } "with" { strcat(LineBuffer, yytext); return(WITH); }
"->" { strcat(LineBuffer, yytext); return(REF); } "->" { strcat(LineBuffer, yytext); return(REF); }
{L}({L}|{D})* { strcat(LineBuffer, yytext); return(IDENTIFIER); } {L}({L}|{D})* { strcpy(identifier, yytext); strcat(LineBuffer, yytext); return(IDENTIFIER); }
{D}+ { strcat(LineBuffer, yytext); return(INTEGER); } {D}+ { strcpy(constant, yytext); strcat(LineBuffer, yytext); return(INTEGER); }
{D}+{E} { strcat(LineBuffer, yytext); return(REAL); } {D}+{E} { strcpy(constant, yytext); strcat(LineBuffer, yytext); return(REAL); }
{D}*"."{D}+({E})? { strcat(LineBuffer, yytext); return(REAL); } {D}*"."{D}+({E})? { strcpy(constant, yytext); strcat(LineBuffer, yytext); return(REAL); }
{D}+"."{D}*({E})? { strcat(LineBuffer, yytext); return(REAL); } {D}+"."{D}*({E})? { strcpy(constant, yytext); strcat(LineBuffer, yytext); return(REAL); }
\"(\\.|[^\\"])*\" { strcat(LineBuffer, yytext); return(STRING); } \"(\\.|[^\\"])*\" { strcpy(constant, yytext); strcat(LineBuffer, yytext); return(STRING); }
":=" { strcat(LineBuffer, yytext); return(ASSIGN); } ":=" { strcat(LineBuffer, yytext); return(ASSIGN); }
"<=" { strcat(LineBuffer, yytext); return(LE); } "<=" { strcat(LineBuffer, yytext); return(LE); }
......
...@@ -194,57 +194,57 @@ AttrPath ...@@ -194,57 +194,57 @@ AttrPath
Type Type
: INTCLASS : INTCLASS
{ {
printf("INTCLASS is |%s|", yytext); printf("INTCLASS is |Integer|");
$$ = create_type(yytext); $$ = create_type("Integer");
} }
| STRCLASS | STRCLASS
{ {
printf("STRCLASS is |%s|", yytext); printf("STRCLASS is |String|");
$$ = create_type(yytext); $$ = create_type("String");
} }
| OID | OID
{ {
printf("OID is |%s|", yytext); printf("OID is |Oid|");
$$ = create_type(yytext); $$ = create_type("Oid");
} }
; ;
AttributeIdentifier AttributeIdentifier
: IDENTIFIER : IDENTIFIER
{ {
printf("AttributeIdentifier is |%s| ", yytext); printf("AttributeIdentifier is |%s| ", identifier);
$$ = create_attr(yytext); $$ = create_attr(identifier);
} }
; ;
TableIdentifier TableIdentifier
: IDENTIFIER : IDENTIFIER
{ {
printf("|%s| ", yytext); printf("|%s| ", identifier);
$$ = create_table(yytext); $$ = create_table(identifier);
} }
; ;
VarIdentifier VarIdentifier
: IDENTIFIER : IDENTIFIER
{ {
printf("|%s| ", yytext); printf("|%s| ", identifier);
$$ = create_var(yytext); $$ = create_var(identifier);
} }
; ;
ReferringType ReferringType
: IDENTIFIER : IDENTIFIER
{ {
printf("ClassIdentifier is |%s| ", yytext); printf("ClassIdentifier is |%s| ", identifier);
$$ = create_rt(yytext); $$ = create_rt(identifier);
} }
; ;
ClassIdentifier ClassIdentifier
: IDENTIFIER : IDENTIFIER
{ {
printf("ClassIdentifier is |%s| ", yytext); printf("ClassIdentifier is |%s| ", identifier);
$$ = create_class(yytext); $$ = create_class(identifier);
} }
; ;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment