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

Fix bug caused by yytext

parent 73d3bfb9
No related branches found
No related tags found
1 merge request!6Rewrite Parsers for SQLP Query, Schema, and Referring Type Expression
......@@ -200,55 +200,55 @@ AttrPath
VarIdentifier
: IDENTIFIER
{
printf("VarIdentifier is |%s| ", yytext);
$$ = create_var(yytext);
printf("VarIdentifier is |%s| ", identifier);
$$ = create_var(identifier);
}
TableIdentifier
: IDENTIFIER
{
printf("TableIdentifier is |%s| ", yytext);
$$ = create_var(yytext);
printf("TableIdentifier is |%s| ", identifier);
$$ = create_var(identifier);
}
AttrIdentifier
: IDENTIFIER
{
printf("AttrIdentifier is |%s| ", yytext);
$$ = create_var(yytext);
printf("AttrIdentifier is |%s| ", identifier);
$$ = create_var(identifier);
}
CompOperator
: EQ
{
printf("CompOperator EQ\n");
$$ = create_op(yytext);
$$ = create_op("=");
}
| NE
{
printf("CompOperator NE\n");
$$ = create_op(yytext);
$$ = create_op("<>");
}
| LE
{
printf("CompOperator LE\n");
$$ = create_op(yytext);
$$ = create_op("<=");
}
| GE
{
printf("CompOperator GE\n");
$$ = create_op(yytext);
$$ = create_op(">=");
}
| LT
{
printf("CompOperator LT\n");
$$ = create_op(yytext);
$$ = create_op("<");
}
| GT
{
printf("CompOperator GT\n");
$$ = create_op(yytext);
$$ = create_op(">");
}
;
......@@ -317,25 +317,25 @@ Term
Integer
: INTEGER
{
printf("INTEGER is |%s|", yytext);
$$ = create_constant(yytext);
printf("INTEGER is |%s|", constant);
$$ = create_constant(constant);
}
Constant
: INTEGER
{
printf("INTEGER is |%s|", yytext);
$$ = create_constant(yytext);
printf("INTEGER is |%s|", constant);
$$ = create_constant(constant);
}
| REAL
{
printf("REAL is |%s|", yytext);
$$ = create_constant(yytext);
printf("REAL is |%s|", constant);
$$ = create_constant(constant);
}
| STRING
{
printf("STRING is |%s|", yytext);
$$ = create_constant(yytext);
printf("STRING is |%s|", constant);
$$ = create_constant(constant);
}
;
No preview for this file type
......@@ -34,7 +34,7 @@ SQLPRefExp
;
OidExpLst
: OidExpLst ';' OidExp
: OidExpLst ';' OidExp
{
printf("OidExpLst\n");
$$ = create_oidexplst_operator($1, $3);
......@@ -86,12 +86,12 @@ Col
AttrPath
: AttrIdentifier
{
{
printf("path id\n");
$$ = create_pf($1, NULL);
}
| AttrIdentifier '.' AttrPath
{
{
printf("Path Function\n");
$$ = create_pf($1, $3);
}
......@@ -100,21 +100,20 @@ AttrPath
VarIdentifier
: IDENTIFIER
{
printf("|%s| ", yytext);
$$ = create_var(yytext);
printf("|%s| ", identifier);
$$ = create_var(identifier);
}
TableIdentifier
: IDENTIFIER
{
printf("|%s| ", yytext);
$$ = create_table(yytext);
printf("|%s| ", identifier);
$$ = create_table(identifier);
}
AttrIdentifier
: IDENTIFIER
{
printf("|%s| ", yytext);
$$ = create_attr(yytext);
printf("|%s| ", identifier);
$$ = create_attr(identifier);
}
......@@ -32,6 +32,8 @@
int LineNumber = 1;
char LineBuffer[200];
char identifier[200];
char constant[200];
%}
%p 3000
......@@ -121,14 +123,14 @@ E [Ee][+-]?{D}+
"with" { strcat(LineBuffer, yytext); return(WITH); }
"->" { 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}+{E} { strcat(LineBuffer, yytext); return(REAL); }
{D}*"."{D}+({E})? { strcat(LineBuffer, yytext); return(REAL); }
{D}+"."{D}*({E})? { strcat(LineBuffer, yytext); return(REAL); }
{D}+ { strcpy(constant, yytext); strcat(LineBuffer, yytext); return(INTEGER); }
{D}+{E} { strcpy(constant, yytext); strcat(LineBuffer, yytext); return(REAL); }
{D}*"."{D}+({E})? { strcpy(constant, yytext); 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(LE); }
......
No preview for this file type
......@@ -194,57 +194,57 @@ AttrPath
Type
: INTCLASS
{
printf("INTCLASS is |%s|", yytext);
$$ = create_type(yytext);
printf("INTCLASS is |Integer|");
$$ = create_type("Integer");
}
| STRCLASS
{
printf("STRCLASS is |%s|", yytext);
$$ = create_type(yytext);
printf("STRCLASS is |String|");
$$ = create_type("String");
}
| OID
{
printf("OID is |%s|", yytext);
$$ = create_type(yytext);
printf("OID is |Oid|");
$$ = create_type("Oid");
}
;
AttributeIdentifier
: IDENTIFIER
{
printf("AttributeIdentifier is |%s| ", yytext);
$$ = create_attr(yytext);
printf("AttributeIdentifier is |%s| ", identifier);
$$ = create_attr(identifier);
}
;
TableIdentifier
: IDENTIFIER
{
printf("|%s| ", yytext);
$$ = create_table(yytext);
printf("|%s| ", identifier);
$$ = create_table(identifier);
}
;
VarIdentifier
: IDENTIFIER
{
printf("|%s| ", yytext);
$$ = create_var(yytext);
printf("|%s| ", identifier);
$$ = create_var(identifier);
}
;
ReferringType
: IDENTIFIER
{
printf("ClassIdentifier is |%s| ", yytext);
$$ = create_rt(yytext);
printf("ClassIdentifier is |%s| ", identifier);
$$ = create_rt(identifier);
}
;
ClassIdentifier
: IDENTIFIER
{
printf("ClassIdentifier is |%s| ", yytext);
$$ = create_class(yytext);
printf("ClassIdentifier is |%s| ", identifier);
$$ = 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