<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">definition
module TIL-calls
imports TIL-expressions TIL-statements
exports
  context-free syntax
    Id "(" {Exp ","}* ")"     -&gt; Exp  {cons("FunCall")}
    Id "(" {Exp ","}* ")" ";" -&gt; Stat {cons("ProcCall")}

module TIL-types
imports TIL-literals
exports 
 sorts Type
  context-free syntax
    Id -&gt; Type {cons("TypeName")}

module TIL-statements
imports TIL-expressions TIL-types
exports 
  sorts Stat
  context-free syntax
    "var" Id ";"			                    -&gt; Stat {cons("Declaration")}
    "var" Id ":" Type ";"			            -&gt; Stat {cons("DeclarationTyped")}
    Id ":=" Exp ";"                             -&gt; Stat {cons("Assign")}
    "begin" Stat* "end"                         -&gt; Stat {cons("Block")}
    "if" Exp "then" Stat* "end"                 -&gt; Stat {cons("IfThen")}
    "if" Exp "then" Stat* "else" Stat* "end"    -&gt; Stat {cons("IfElse")}
    "while" Exp "do" Stat* "end"                -&gt; Stat {cons("While")}
    "for" Id ":=" Exp "to" Exp "do" Stat* "end" -&gt; Stat {cons("For")}

module TIL-expressions
imports TIL-literals
exports 
  sorts Exp
  context-free syntax
    "true"       -&gt; Exp {cons("True")}
    "false"      -&gt; Exp {cons("False")}
    Id           -&gt; Exp {cons("Var")}
    Int          -&gt; Exp {cons("Int")}
    String       -&gt; Exp {cons("String")}
    Exp "*" Exp  -&gt; Exp {cons("Mul"),assoc}
    Exp "/" Exp  -&gt; Exp {cons("Div"),assoc}
    Exp "%" Exp  -&gt; Exp {cons("Mod"),non-assoc}
    Exp "+" Exp  -&gt; Exp {cons("Add"),assoc}
    Exp "-" Exp  -&gt; Exp {cons("Sub"),left}
    Exp "&lt;" Exp  -&gt; Exp {cons("Lt"),non-assoc}
    Exp "&gt;" Exp  -&gt; Exp {cons("Gt"),non-assoc}
    Exp "&lt;=" Exp -&gt; Exp {cons("Leq"),non-assoc}
    Exp "&gt;=" Exp -&gt; Exp {cons("Geq"),non-assoc}
    Exp "=" Exp  -&gt; Exp {cons("Equ"),non-assoc}
    Exp "!=" Exp -&gt; Exp {cons("Neq"),non-assoc}
    Exp "&amp;" Exp  -&gt; Exp {cons("And"),assoc}
    Exp "|" Exp  -&gt; Exp {cons("Or"),assoc}
    "(" Exp ")"  -&gt; Exp {bracket}
  context-free priorities
    {left: 
       Exp "*" Exp -&gt; Exp 
       Exp "/" Exp -&gt; Exp }
  &gt; {left: 
       Exp "+" Exp -&gt; Exp 
       Exp "-" Exp -&gt; Exp }
  &gt; {non-assoc: 
       Exp "&lt;" Exp  -&gt; Exp 
       Exp "&gt;" Exp  -&gt; Exp
       Exp "&lt;=" Exp -&gt; Exp 
       Exp "&gt;=" Exp -&gt; Exp
       Exp "="  Exp -&gt; Exp 
       Exp "!=" Exp -&gt; Exp }
  &gt; Exp "&amp;" Exp  -&gt; Exp
  &gt; Exp "|" Exp  -&gt; Exp


module TIL-literals
exports 
  sorts Id Int String StrChar
  lexical syntax
    [A-Za-z][A-Za-z0-9]* -&gt; Id
    [0-9]+               -&gt; Int
    "\"" StrChar* "\""   -&gt; String
    ~[\"\\\n]            -&gt; StrChar
    [\\][\"\\n]          -&gt; StrChar
  lexical restrictions
    Id  -/- [A-Za-z0-9]
    Int -/- [0-9]

module TIL-layout
exports 
  lexical syntax
    [\ \t\n\r]    -&gt; LAYOUT
    "//" ~[\n\r]* -&gt; LAYOUT
  context-free restrictions
    LAYOUT? -/- [\ \t\n\r]

module TIL
imports TIL-layout TIL-literals TIL-expressions TIL-statements TIL-calls
exports 
  sorts Program
  context-free syntax
    Stat* -&gt; Program {cons("Program")}

  context-free start-symbols Program</pre></body></html>