/** * Defines a decent language called "Fun" on top of the language * "fragments" defined in: * - unsignedArith.l * - logic.l * - pairs.l * - locals.l * - intLiterals.l * * @author Jacob Andersen */ "intLiterals.l" + { Wsp = [\ \n\r] ; Comment = ("//" [^\n\r]*) | ("/*" ([^*/] | (\* [^/]))* "*/") ; _ = ( | )* ; __ = ( | )+ ; Id = [a-zA-Z][0-9a-zA-Z_]* ; Exp.letexp : _ LetExp _ ; LetExp.letvar : "let" __ Id _ "=" _ LetExp _ "in" _ LetExp ; LetExp.letfun : "let" __ Id _ "(" _ Id _ ")" _ "=" _ LetExp _ "in" _ LetExp ; LetExp.letrec : "letrec" __ Id _ "(" _ Id _ ")" _ "=" _ LetExp _ "in" _ LetExp ; LetExp.if : OrExp _ "?" _ LetExp _ ":" _ LetExp ; LetExp.orexp : OrExp ; OrExp.or : OrExp _ "|" _ AndExp ; OrExp.xor : OrExp _ "^" _ AndExp ; OrExp.andexp : AndExp ; AndExp.and : AndExp _ "&" _ NotExp ; AndExp.notexp : NotExp ; NotExp.not : "!" _ RelExp ; NotExp.relexp : RelExp ; RelExp.simple : SimpleExp ; SimpleExp.uplus : "+" _ Term ; SimpleExp.uminus : "-" _ Term ; SimpleExp.add : SimpleExp _ "+" _ Term ; SimpleExp.sub : SimpleExp _ "-" _ Term ; SimpleExp.term : Term ; Term.mul : Term _ "*" _ Factor ; Term.factor : Factor ; Factor.facparen : FacParen ; Factor.noparen : FacNoPar ; FacParen.paren : "(" _ LetExp _ ")" ; FacParen.app : Factor _ "(" _ LetExp _ ")" ; FacParen.iszero : "zero?" _ "(" _ LetExp _ ")" ; FacParen.succ : "++" _ "(" _ LetExp _ ")" ; FacParen.pred : "--" _ "(" _ LetExp _ ")" ; FacParen.cons : "cons" _ "(" _ LetExp _ "," _ LetExp _ ")" ; FacParen.car : "car" _ "(" _ LetExp _ ")" ; FacParen.cdr : "cdr" _ "(" _ LetExp _ ")" ; FacNoPar.app1 : FacNoPar __ Prim ; FacNoPar.app2 : FacParen _ Prim ; FacNoPar.iszero : "zero?" __ Prim ; FacNoPar.succ : "++" _ Prim ; FacNoPar.pred : "--" _ Prim ; FacNoPar.car : "car" __ Prim ; FacNoPar.cdr : "cdr" __ Prim ; FacNoPar.prim : Prim ; Prim.true : "#t" ; Prim.false : "#f" ; Prim.var : Id ; Prim.intConst : IntConst ; }