Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 843b9afc1e
Fetching contributors…

Cannot retrieve contributors at this time

192 lines (140 sloc) 4.146 kb
*************************************************************
This page provides you with the definition of the Yadi-0.4 Datalog syntax,
/* Grammar */
main: EOP { failwith "Empty command or query!"}
| program EOP
| commlist EOP
program:
| exprlist
commlist:
| command
exprlist:
| expr
| exprlist expr
expr:
| rule
| query
command:
| TESTCOMM RELNAME
| RECONNECT reconn_param VAL reconn_param pass_param reconn_param /* host port user password db_name*/
| CHANGEOUT file_name
| READSCR file_name
| QUITCOMM
| UNKNOWNCOMM
| GETTABLECOMM
| GETDBCOMM
| HELPCOMM help_param
| TABINFOCOMM VARNAME /*table name*/
;
help_param:
| SELECT
| JOIN
| WHERE
| WHERENOT
| UNION
| ISODD
| ISEVEN
| VARNAME
;
file_name:
| reconn_param DOT reconn_param
| reconn_param
reconn_param:
| ANYNAME
| RELNAME
| VARNAME
;
pass_param:
| ANYNAME
| RELNAME
| VARNAME
| PASSNAME
| BOOLPRED
;
rule:
head IMPLIEDBY body DOT
head:
predicate
body:
litlist
query:
| QMARK predicate DOT
litlist: /* empty */
| literal
| litlist AND literal
literal:
| predicate
| NOT predicate
| equality
| NOT equality
| booleanpredicate
| NOT booleanpredicate
;
predicate:
RELNAME LPAREN termlist RPAREN
bodypredicate:
RELNAME LPAREN bodytermlist RPAREN
;
booleanpredicate:
BOOLPRED LPAREN termlist RPAREN
;
comparison:
term compsym term
;
compsym:
| LE /* less */
| GR /* greater */
| LQ /* less equal*/
| GQ /* greater equal */
| NE /* not equal */
| EQ /* equal */
;
termlist: /* empty */
| term
| term SEP termlist /* \!/ rec. on the right */
bodytermlist: /* empty */
| bodyterm
| bodyterm SEP bodytermlist /* \!/ rec. on the right */
term:
|VARNAME
|VAL
;
bodyterm:
| VARNAME
| VAL
| ANON_VAR
/* tokens declaration */
%token <int> VAL /* token with int value */
%token <string> RELNAME /* token with string value */
%token <string> VARNAME /* token with string value */
%token <string> BOOLPRED /* token with string value */
%token QMARK DOT IMPLIEDBY
%token AND NOT ANON_VAR
%token SELECT JOIN WHERE WHERENOT UNION ISODD ISEVEN /*token for help parameters*/
%token EQ LE GR LQ GQ NE
%token LPAREN RPAREN SEP
%token EOP
%token ANON /* fake token to stop the grammar in the fact rule */
%token TESTCOMM RECONNECT QUITCOMM CHANGEOUT READSCR HELPCOMM UNKNOWNCOMM TABINFOCOMM GETTABLECOMM GETDBCOMM
%token <string> ANYNAME /* mytoken with string value */
%token <string> PASSNAME /* mytoken with string value */
/* associativity and precedence when needed */
%nonassoc IMPLIEDBY
/*Helpers*/
QMARK = '-?'
DOT = '.'
IMPLIEDBY = ':-'
AND = 'and'
NOT = 'not'
LPAREN = '('
RPAREN = ')'
SEP = ','
EQ = '='
EOP = '/'
ANYNAME = ['A'-'Z' 'a'-'z']['A'-'Z' 'a'-'z' '0'-'9' '_' '-']*
PASSNAME = ['A'-'Z' 'a'-'z' '0'-'9' '_' '-']+
RELNAME = ['A'-'Z']['a'-'z']*
VAL = ['0'-'9']
RECONNECT = #reconnect
QUITCOMM = #quit
*************************************************************
Jump to Line
Something went wrong with that request. Please try again.