next up previous
Next: XML Document Type Definition Up: The ClassAd Language Reference Previous: Bibliography


YACC Grammar

%token ERROR
%token FALSE
%token IDENTIFIER
%token INTEGER
%token LEX_ERROR
%token REAL
%token STRING
%token TRUE
%token UNDEFINED

%left OP_LOR
%left OP_LAND
%left '|'
%left '^'
%left '&'
%left OP_EQ OP_NE OP_IS OP_ISNT
%left '<' '>' OP_LE OP_GE
%left OP_SHL OP_SHR OP_SHRR
%left '+' '-'
%left '*' '/' '%' 
%left UNARY

%%
Expression
    : Expr 
    | Expr '?' Expression ':' Expression
    ;
Expr
    : Expr OP_LOR Expr 
    | Expr OP_LAND Expr 
    | Expr '|' Expr 
    | Expr '^' Expr 
    | Expr '&' Expr 
    | Expr OP_EQ Expr 
    | Expr OP_NE Expr 
    | Expr OP_IS Expr 
    | Expr OP_ISNT Expr 
    | Expr '<' Expr 
    | Expr '>' Expr 
    | Expr OP_LE Expr 
    | Expr OP_GE Expr 
    | Expr OP_SHL Expr 
    | Expr OP_SHR Expr 
    | Expr OP_SHRR Expr 
    | Expr '+' Expr 
    | Expr '-' Expr 
    | Expr '*' Expr
    | Expr '/' Expr 
    | Expr '%' Expr 
    | PrefixExpr
    ;
PrefixExpr
    : SuffixExpr
    | '+' PrefixExpr %prec UNARY
    | '-' PrefixExpr %prec UNARY
    | '!' PrefixExpr %prec UNARY
    | '~' PrefixExpr %prec UNARY
    ;
SuffixExpr
    : Atom
    | SuffixExpr '.' Identifier
    | SuffixExpr '[' Expression ']'
    ;
Atom
    : Identifier
    | Literal
    | List
    | Record
    | Call
    | '(' Expression ')'
    ;
List
    : '{' ListBody ListEnd
    | '{' ListEnd
    ;
ListEnd
    : '}'
    | ',' '}'
    ;
ListBody
    : Expression
    | ListBody ',' Expression
    ;
Record
    : '[' DefinitionList RecordEnd
            Expr e = (Expr) i.next();
            if (r.lookup(n) != null)
    | '[' RecordEnd
    ;
RecordEnd
    : ']'
    | ';' ']'
    ;
DefinitionList
    : Identifier '=' Expression
    | DefinitionList ';' Identifier '=' Expression
    ;
Call
    : Identifier '(' ListBody ')'
    | Identifier '(' ')'
    ;
Literal
    : REAL
    | Strings
    | INTEGER
    | TRUE
    | FALSE
    | UNDEFINED
    | ERROR
    ;
Strings
    : STRING
    | Strings STRING
    ;
Identifier
    : IDENTIFIER
    ;



Alain Roy 2004-09-30