class Id. token : "{letter}({letter}|{digit})*". end class Id. class Operator. token : defined in subclass. of Integer1 and Integer2 : defined in subclass. end class Operator. class RelOp extends Operator. token : <; <=; >; >=; =; <>. of Integer1 and Integer2 : Lexeme = <, Integer1 < Integer2. of Integer1 and Integer2 : Lexeme = <=, Integer1 <= Integer2. of Integer1 and Integer2 : Lexeme = >, Integer1 > Integer2. of Integer1 and Integer2 : Lexeme = >=, Integer1 >= Integer2. of Integer1 and Integer2 : Lexeme = =, Integer1 = Integer2. of Integer1 and Integer2 : Lexeme = <>, Integer1 != Integer2. end class RelOp. class ArithmeticOperator extends Operator. end class ArithmeticOperator. class AddOp extends ArithmeticOperator. token : +; -. of Integer1 and Integer2 : Lexeme = +, Integer1 + Integer2. of Integer1 and Integer2 : Lexeme = -, Integer1 + Integer2. end class AddOp. class MultOp extends ArithmeticOperator. token : *; /. of Integer1 and Integer2 : Lexeme = *, Integer1 * Integer2. of Integer1 and Integer2 : Lexeme = /, Integer2 = 0, Integer1 / Integer2. end class MultOp. class Store. StoreMap :: map Id to Integer. access with Id : apply StoreMap to Id. update Id with Integer : update StoreMap with Id mapped to Integer. end class Store. class File extends IntegerList. end class File. class Configuration. Store :: Store. InputFile, OutputFile :: File. end class Configuration. class Program. InputFile, OutputFile :: File. Syntax :: Series '.'. semantics with InputFile : Configuration new InputFile, Series semantics with Configuration, Configuration getOutputFile. end class Program. class Series. Syntax :: Statement; Series ';' Statement. semantics with Configuration : isSyntax Statement, Statement semantics with Configuration; isSyntax Series ';' Statement, Series semantics with Configuration, Statement semantics with Configuration. end class Series. class Statement. InputFile, OutputFile :: File. Syntax :: IOStatement; AssignStatement; IfThenStatement; ToStatement; WhileStatement. extractConfigurationComponents : Store := Configuration getStore, InputFile := Configuration getInputFile, OutputFile := Configuration getOutputFile. semantics with Configuration : defined in subclass. end class Statement. class IOStatement extends Statement. IdListHead :: Id. IdListTail :: IdList. Syntax :: read Ids; write Ids. semantics with Configuration : extractConfigurationComponents, IdList := semantics of Ids, io IdList. io IdList : isSyntax read Ids, read IdList with Store and InputFile, Configuration setStore Store, Configuration setInputFile InputFile; isSyntax write Ids, write IdList with Store and OutputFile, Configuration setOutputFile OutputFile; read Empty with Store and InputFile. read Id IdList with Store and InputFile : InputFile != Empty, Integer := InputFile head, Store update Id with Integer, InputFile := InputFile tail, read IdList with Store and InputFile. write Empty with Store and OutputFile. write Id IdList with Store and OutputFile : Integer := Store access Id, OutputFile := OutputFile append list Integer, write IdList with Store and OutputFile. end IOStatement. class Ids. Syntax :: Id; Ids ',' Id. semantics : isSyntax Id, list Id; isSyntax Ids ',' Id, IdList := Ids semantics, IdList append list Id. end class Ids. class AssignStatement extends Statement. Syntax :: Id := Expression. semantics with Configuration : extractConfigurationComponents, Integer := semantics of Expression with Store, Store update Id with Integer, Configuration setStore Store. end class AssignStatement. class ConditionalSemantics. semantics of conditional : semantics of condition, semantics of then part; semantics of condition failure, semantics of else part. semantics of condition : defined in subclass. semantics of condition fails : not semantics of condition. semantics of then part : defined in subclass. semantics of else part. end class ConditionalSemantics. class IfThenStatement extends Statement, ConditionalSemantics. Syntax :: if Comparison then Series fi. semantics with Configuration : extractConfigurationComponents, semantics of conditional. semantics of condition : semantics of Comparison with Store. semantics of then part : semantics of Series with Configuration. end class IfThenStatement. class IfThenElseStatement extends IfThenStatement. Syntax :: if Comparison then Series else Series1 fi. semantics with Configuration : extractConfigurationComponents, semantics of conditional. semantics of else part : semantics of Series1 with Configuration. end IfThenElseStatement. class LoopSemantics. semantics of pretest loop : semantics of condition, semantics of loop body, semantics of pretest loop. semantics of posttest loop : semantics of loop body, semantics of condition, semantics of posttest loop. semantics of condition : defined in subclass. semantics of loop body : defined in subclass. end class LoopSemantics. class ToStatement extends Statement, LoopSemantics. RepetitionFactor :: Integer. Syntax :: to Expression do Series end. semantics with Configuration : extractConfigurationComponents, RepetitionFactor := semantics of Expression with Store, semantics of posttest loop. semantics of condition : RepetitionFactor > 0. semantics of loop body : semantics of Series with Configuration, RepetitionFactor := RepetitionFactor - 1. end class ToStatement. class WhileStatement extends Statement, LoopSemantics. Syntax :: while Comparison do Series end. semantics with Configuration : extractConfigurationComponents, semantics of pretest loop. semantics of condition : semantics of Comparison with Store. semantics of loop body : semantics of Series with Configuration. end class WhileStatement. class Operation. Syntax :: Expression1 Operator Expression2. semantics with Store : Integer1 := Expression1 semantics with Store, Integer2 := Expression2 semantics with Store, Operator of Integer1 and Integer2. end class Operation. class Comparison extends Operation. Syntax :: Expression1 RelOp Expression2. end class Comparison. class Expression extends Operation. Expression :: Expression ArithmeticOperator Expression; UnsignedInteger; Id. Syntax :: Expression1 AddOp Expression2; Expression1 MultOp Expression2; ( Expression ); UnsignedInteger; Id. precedence left AddOp. precedence left MultOp. semantics with Store : isSyntax Expression1 ArithmeticOperator Expression2, super semantics with Store; isSyntax UnsignedInteger, UnsignedInteger; isSyntax Id, Store access with Id. end class Expression.