LEXICAL SPECIFICATION (Tokenizer.java) ============================================================================ string := "([^\\]|\\.)*?" | """([^\\]|\\.)*?""" Either a "quoted string with \" \\ escaping" or: """tripled quoted strings, which allow "quotes" inside them""" Both types of quoting allow interpolation of variables, so $ signs must be escaped when meant literally. ident := [a-zA-Z_] [a-zA-Z0-9_]* integer := [0-9]+ VarRef := "$" ("."|"*")? ident ( "." ident )* | "${" ("."|"*")? ident ( "." ident )* "}" ws := [ \n\t\r]+ doublecolon := "::" NativeType := "bool" | "string" | "int" DocString := GRAMMAR ============================================================================ Layer.java: ------------------------- Layer := * LayerContents := LayerInfo | ClassDecl | FuncDecl | FuncDef | Prop | Set NodeLayerInfo.java ------------------------- LayerInfo := "layerinfo" "=" ";" NodeText.java ------------------------- Text := | | NodeClass.java ------------------------- ClassDecl := "class" ( "extends" )? ? "{" ClassItemDecl* "}" ClassItemDecl := ClassVarDecl | FuncDecl ClassVarDecl := "var" DocString? ";" NodeProperty.java ------------------------- Prop := "property" "builtin" Type ident ";" | "property" Type ident "{" * "}" | "property" ("use" | "hide") Type ";" NodePropertyPair.java ------------------------- PropertyPair := "=" ";" NodeSet.java ------------------------- Set := "set" "=" ";" NodeFunction.java ------------------------- FuncReturn := ":" FuncDecl := "function" "builtin"? FuncArgs? FuncReturn? DocString? ";" FuncArgs := "(" FuncArgItem ("," FuncArgItem)* ")" FuncArgItem := FuncDef := "function" ( "::")? FuncArgs? FuncReturn? DocString? VarDeclStmt := "var" ";" Expr := AssignExpr := ({"="} )? CondExpr := ("?" ":" ) LogOrExpr := ({"or"|"xor"} )? LogAndExpr := ("and" )? EqualExpr := ({"=="|"!="} )? RelationExpr := ({"<"|"<="|">"|">="} )? SumExpr := ({"+"|"-"} )? MultExpr := ({"*"|"/"|"%"} )? UnaryNegation = {"not"|"-"}? IncExpr = {"--"|"++"} | {"--"|"++"} | Term := | | VarRef | ParenExpr | CallExpr ParenExpr := "(" ")" CallExpr := "(" ArgList ")" ArgList := (Expr ("," Expr)*)? Type := SimpleType ("[]"|"{}")* StmtBlock := "{" Stmt* "}" Stmt := PrintStmt | IfStmt | ForeachStmt PrintStmt := {"print" | "println"} ";" ForeachVarDecl = "var" ForeachStmt := "foreach" { | } "(" ")" IfStmt := "if" "(" ")" ( "elseif" )* ( "else" )?