/**************************************** ** syntax file for the ACTION! language ** Created Feb 12, 2010 ** By Jim Patchell ****************************************/ [ event driven grammar token = action sticky {fund decl} enum { eof = 0, SPACE = ' ', AND = 'A', ANDassign, // =& OR, // OR ORassign, // =| XORassign, // =% ADDassign, // =+ SUBassign, // =- MULassign, // =* DIVassign, // =/ MODassign, // =MOD LSHassign, // ==RSH RSHassign, // ==LSH EQUAL, // == NEQ, // <> GTE, // >= LTE, // <= STRING, ARRAY, POINTER, BYTE, CARD, INT, TYPE, TYPEDEF, IDENTIFIER, CONSTANT, DO, OD, IF, ELSEIF, ELSE, FI, FOR, TO, STEP, WHILE, UNTIL, EXIT, PROC, FUNC, RETURN, BEGIN, END, MODULE, LSH, RSH, MOD, THEN, CHAR, HEX_CONSTANT, CHAR_CONSTANT, DEFINE, XOR } // left {OR} // left {AND} // left {'>','<',GRTRTHANEQ,LESSTHANEQ,NOTEQUAL,EQUAL} // left {'&','|','%'} // left {RSH,LSH} // left {'+','-'} // left {'*','/',MOD} parser file name = "action.c" header file name = "action.h" ] action -> action, MODULE, prog module -> MODULE, prog module ->prog module prog module -> system decls, routine list -> routine list system decls -> DEFINE decl ->TYPE decl -> var decl DEFINE decl -> DEFINE, def list def list -> def ->def list, ',', def def -> IDENTIFIER, '=', num const TYPE decl -> TYPE, rec ident list rec ident list -> rec ident ->rec ident list, ',', rec ident rec ident -> IDENTIFIER, '[',field init,']' field init ->var decl var decl -> var decl, base var decl -> base var decl base var decl -> fund decl ->POINTER decl ->ARRAY decl ->record decl fund decl ->fund decl, base fund decl -> base fund decl base fund decl -> fund type, fund ident list fund type ->BYTE ->CHAR ->CARD ->INT fund ident list ->fund ident ->fund ident list, ',',fund ident fund ident ->IDENTIFIER ->IDENTIFIER, '=', init opts init opts ->addr ->'[',init value,']' addr ->comp const init value ->num const POINTER decl ->ptr type, POINTER, ptr ident list ptr type ->fund type ->TYPEDEF ptr ident list ->ptr ident ->ptr ident list,',',ptr ident ptr ident ->IDENTIFIER ->IDENTIFIER,'=',value ARRAY decl ->fund type, ARRAY, arr ident list arr ident list ->arr ident ->arr ident list,',',arr ident arr ident ->IDENTIFIER ->IDENTIFIER,'(',dim,')' ->IDENTIFIER,'=',arr init opts ->IDENTIFIER,'(',dim,')','=',arr init opts dim -> num const arr init opts ->addr ->'[',value list,']' ->str const value list -> value ->value list, value record decl ->TYPEDEF, record ident list record ident list ->record ident ->record ident list, ',',record ident record ident ->IDENTIFIER ->IDENTIFIER,'=',addr mem reference ->mem contents ->'@',IDENTIFIER mem contents ->fund ref ->arr ref ->ptr ref ->rec ref fund ref ->IDENTIFIER arr ref ->IDENTIFIER,'(',arith exp,')' ptr ref -> IDENTIFIER, '^' rec ref -> IDENTIFIER, ',', IDENTIFIER routine list -> routine -> routine list, routine routine ->proc routine ->func routine proc routine ->PROC decl,opt system decls, opt stmt list, opt proc return PROC decl ->PROC, IDENTIFIER,opt proc init, '(', opt param decl,')' opt proc init -> -> '=',addr opt system decls -> -> system decls opt proc return -> -> RETURN func routine ->FUNC decl, opt system decls,opt stmt list,opt func return FUNC decl ->fund type, FUNC, IDENTIFIER, opt proc init, '(', opt param decl, ')' opt param decl -> ->param decl opt func return -> ->RETURN, arith exp routine call ->IDENTIFIER, '(', call param list ,')' ->IDENTIFIER, '(',')' call param list ->param ->call param list,',',param param ->arith exp param decl ->var decl stmt list ->stmt ->stmt list, stmt stmt ->simp stmt ->struct stmt ->code block simp stmt ->assign stmt ->EXIT stmt ->routine call struct stmt ->IF stmt ->DO loop ->WHILE loop ->FOR loop assign stmt ->mem contents, '=', arith exp ->mem contents, ANDassign, arith exp ->mem contents, ADDassign, arith exp ->mem contents, DIVassign, arith exp ->mem contents, MULassign, arith exp ->mem contents, SUBassign, arith exp ->mem contents, MODassign, arith exp ->mem contents, ORassign, arith exp ->mem contents, RSHassign, arith exp ->mem contents, LSHassign, arith exp ->mem contents, XORassign, arith exp EXIT stmt ->EXIT IF stmt ->IF, cond exp, THEN, opt stmt list, opt ELSEIF, opt ELSE, FI opt ELSEIF -> ->ELSEIF, cond exp, THEN,opt stmt list opt ELSE -> ->ELSE, opt stmt list DO loop ->DO, opt stmt list, opt until,OD opt stmt list -> ->stmt list opt until -> ->UNTIL,cond exp WHILE loop ->WHILE, cond exp, DO loop FOR loop ->FOR, IDENTIFIER, '=', start, TO, finish, opt STEP opt STEP -> ->STEP,inc start ->arith exp finish ->arith exp inc ->arith exp code block -> '[', comp const list, ']' comp const list -> comp const ->comp const list, comp const cond exp ->complex rel complex rel ->complex rel, special op, simp rel exp // ->simp rel exp, special op, simp rel exp ->simp rel exp simp rel exp ->arith exp, rel op, arith exp ->arith exp arith exp ->arith exp, add op, mult exp ->mult exp mult exp -> mult exp, mul op, value ->value value -> num const ->mem reference -> '(', arith exp, ')' special op ->AND ->OR ->'&' ->'%' rel op ->XOR ->'=' ->'!' ->'#' ->'<' ->'>' ->NEQ ->GTE ->LTE add op ->'+' ->'-' mul op ->'*' ->'/' ->MOD ->LSH ->RSH str const ->STRING comp const ->base comp const ->comp const, '+', base comp const base comp const ->IDENTIFIER ->num const ->ptr ref ->'*' num const ->HEX_CONSTANT ->CONSTANT ->CHAR_CONSTANT