Generating Software from Specifications WS 2013/14 - File parsing1Sol.fw
@=~ ~p maximum_input_line_length = infinity This file contains the specification of a language for sequences of statements. Try to generate a processor for it. If the parser generation indicates problems, analyse their reasons and eliminate them. The following file contains correct input for the processor: Give an example for correct input: ~O~<whileSeq.ok~>~{~- a = b; while c do c = d; i = k; ~} The following file specifies the concrete syntax: ~O~<whileSeq.conx~>~{ Program: Statements. Statements: Statements Statement / Statement. Statement: 'while' Expression 'do' Statements / Ident '=' Expression ';'. Expression: Ident. ~} It is ambigouous: It can not be decided which statements following 'do' belong to the loop or to the surrounding statement sequence. The following grammar allows only one statement in a loop body: (Change the file type into .con to use this grammar.) ~O~<whileSeq.cony~>~{ Program: Statements. Statements: Statements Statement / Statement. Statement: 'while' Expression 'do' Statement / Ident '=' Expression ';'. Expression: Ident. ~} The following grammar closes the loop body by the keyword 'end': (Change the file type into .con to use this grammar.) ~O~<whileSeq.conz~>~{ Program: Statements. Statements: Statements Statement / Statement. Statement: 'while' Expression 'do' Statements 'end' / Ident '=' Expression ';'. Expression: Ident. ~} The following file specifies the non-literal tokens: ~O~<Expression.gla~>~{ Ident: C_IDENTIFIER ~}
Generiert mit Camelot | Probleme mit Camelot? | Geändert am: 13.11.2013