Traductores e Intérpretes UCAB : Gramática SOberon
This page last changed on Nov 29, 2007 by carlos.gonzalez.
Gramática del Lenguaje SOberonLa siguiente gramática está escrita en uno de los estilos de BNF:
Deben tomar en cuenta que:
La Gramática module = "MODULE" ident ";" [ImportList] DeclarationSequence ImportList = "IMPORT" ident {"," ident} ";" DeclarationSequence = {"CONST" {ConstantDeclaration ";"} | ConstantDeclaration = ident "=" ConstExpression ConstExpression = expression expression = SimpleExpression [relation SimpleExpression] SimpleExpression = ["+"|"-"] term {AddOperator term} term = factor {MulOperator factor} factor = number | CharConstant | string | CharConstant = '"' character '"' string = '"' {character} '"' designator = qualident {"." ident | "[" ExpList "]" | "(" qualident ")" } ExpList = expression {"," expression} ActualParameters = "(" [ExpList] ")" MulOperator = "*" | "/" | "DIV" | "MOD" | "&" AddOperator = "+" | "-" | "OR" relation = "=" | "#" | "<" | "<=" | ">" | ">=" TypeDeclaration = ident "=" type type = qualident | ArrayType | RecordType | PointerType | ProcedureType qualident = [ident "."] ident ArrayType = "ARRAY" length {"," length} "OF" type length = ConstExpression RecordType = "RECORD" ["(" BaseType ")"] FieldListSequence "END" BaseType = qualident FieldListSequence = FieldList {";" FieldList} FieldList = [IdentList ":" type] IdentList = ident {"," ident} ProcedureType = "PROCEDURE" [FormalParameters] VariableDeclaration = IdentList ":" type ProcedureDeclaration = ProcedureHeading ";" ProcedureBody ident ProcedureHeading = "PROCEDURE" ident [FormalParameters] FormalParameters = "(" [FPSection {";" FPSection}] ")" [":" qualident] FPSection = ["VAR"] ident {"," ident} ":" FormalType FormalType = {"ARRAY" "OF"} qualident ProcedureBody = DeclarationSequence ["BEGIN" StatementSequence] "END" StatementSequence = statement {";" statement} statement = [assignment | ProcedureCall | IfStatement | CaseStatement | assignment = designator ":=" expression ProcedureCall = designator [ActualParameters] IfStatement = "IF" expression "THEN" StatementSequence CaseStatement = "CASE" expression "OF" case CaseLabelList = CaseLabels WhileStatement = "WHILE" expression "DO" StatementSequence "END" RepeatStatement = "REPEAT" StatementSequence "UNTIL" expression LoopStatement = "LOOP" StatementSequence "END" ident = letter {letter | digit} letter = "A" .. "Z" | "a" .. "z" number = digit {digit} digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" comment = "(" any ")" donde any representa cualquier cadena de caracteres que no incluya "(" ni ")". Links Importantes
|
Document generated by Confluence on Oct 04, 2010 11:25 |