Skip to content
Snippets Groups Projects
Commit ffa56bef authored by eva's avatar eva
Browse files

outline for SQLP schema grammar

parent deea1dda
No related branches found
No related tags found
2 merge requests!5Dev Merge into Master,!2Schema+RefExp Translation Rule 1
......@@ -75,6 +75,7 @@ E [Ee][+-]?{D}+
"mod" { strcat(LineBuffer, yytext); return(MOD); }
"not" { strcat(LineBuffer, yytext); return(NOT); }
"of" { strcat(LineBuffer, yytext); return(OF); }
"Oid" { strcat(LineBuffer, yytext); return(OID); }
"on" { strcat(LineBuffer, yytext); return(ON); }
"one" { strcat(LineBuffer, yytext); return(ONE); }
"or" { strcat(LineBuffer, yytext); return(OR); }
......@@ -91,6 +92,7 @@ E [Ee][+-]?{D}+
"schema" { strcat(LineBuffer, yytext); return(SCHEMA); }
"select" { strcat(LineBuffer, yytext); return(SELECT); }
"selectivity" { strcat(LineBuffer, yytext); return(SELECTIVITY); }
"self" { strcat(LineBuffer, yytext); return(SELF); }
"size" { strcat(LineBuffer, yytext); return(SIZE); }
"space" { strcat(LineBuffer, yytext); return(SPACE); }
"static" { strcat(LineBuffer, yytext); return(STATIC); }
......
%{
#include "util_new.h"
%}
%define api.value.type {cons_cell *}
%token IMPLIES OR AND NOT LE GE LT GT NE HAS MAX MIN AS ASC DESC MOD ASSIGN EQ STAR COMMA DOT
%token SIZE SELECTIVITY OVERLAP
%token FREQUENCY UNIT TIME SPACE
%token IDENTIFIER CONSTANT STRING_LITERAL SIZEOF
%token STORE STORING DYNAMIC STATIC OF TYPE ORDERED BY
%token INDEX LIST ARRAY BINARY TREE DISTRIBUTED POINTER
%token SCHEMA CLASS ISA PROPERTIES CONSTRAINTS PROPERTY
%token ON DETERMINED COVER QUERY GIVEN FROM SELECT WHERE ORDER
%token PRECOMPUTED ONE EXIST FOR ALL TRANSACTION INTCLASS STRCLASS
%token INTEGER REAL DOUBLEREAL STRING MAXLEN RANGE TO
%token INSERT END CHANGE DELETE DECLARE RETURN UNION UNIONALL
%token LIMIT DISTINCT
%start SQLPSchema
%%
SQLPSchema
: TableDefn
{
printf("Input Schema\n");
cons_cell *n = $1;
printf("Printing Tree\n");
print_cons_tree(n);
}
;
TableDefn
: CLASS ClassIdentifier'('ClassSpecs')'
{
printf("TableDefn\n");
}
;
ClassSpecs
: Self
{
printf("ClassSpecs\n");
}
|
: ClassSpecs',' ClassAttributes
{
printf("ClassSpecs\n");
}
|
: ClassSpecs',' ForeignKeys
{
printf("ClassSpecs\n");
}
|
: ClassSpecs',' Specialization
{
printf("ClassSpecs\n");
}
|
: ClassSpecs',' DisjointConstraints
{
printf("ClassSpecs\n");
}
;
Self
: SELF OID
{
printf("Self\n");
}
;
ClassAttributes
: AttributeIdentifier Type
{
printf("ClassAttributes\n");
}
|
: ClassAttributes',' ClassAttributes
{
printf("ClassAttributes\n");
}
;
ForeignKeys
: FOREIGN KEY AttributeIdentifier REFERENCES ClassIdentifier
{
printf("ForeignKeys\n");
}
|
: ForeignKeys',' ForeignKeys
{
printf("ForeignKeys\n");
}
;
Specialization
: ISA ClassIdentifier
{
printf("Specialization\n");
}
|
: Specialization',' Specialization
{
printf("Specialization\n");
}
;
DisjointConstraints
: DISJOINT WITH ClassIdentifier
{
printf("DisjointConstraints\n");
}
|
: DisjointConstraints',' DisjointConstraints
{
printf("DisjointConstraints\n");
}
;
Type
: INTCLASS
{
printf("Type\n");
}
|
: STRCLASS
{
printf("Type\n");
}
|
: OID
{
printf("Type\n");
}
AttributeIdentifier
: IDENTIFIER
{
printf("ClassIdentifier is |%s| ", yytext);
$$ = create_var(yytext);
}
;
ClassIdentifier
: IDENTIFIER
{
printf("ClassIdentifier is |%s| ", yytext);
$$ = create_var(yytext);
}
;
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