home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / interpre / pl / pl_bnf.txt < prev    next >
Text File  |  1989-12-16  |  2KB  |  51 lines

  1. This is the Backus-Naur form of PL:
  2.  
  3. Program = Block ".".
  4. Block = "begin" DefinitionPart StatementPart "end".
  5. DefinitionPart = { Definition ";" }.
  6. Definition = ConstantDefinition | VariableDefinition |                                                                                                                     
  7.    ProcedureDefinition .
  8. ConstantDefinition = "const" ConstantName "=" Constant .
  9. VariableDefinition = TypeSymbol VariableList |   
  10.    TypeSymbol "array" VariableList "[" Constant "]" .
  11. TypeSymbol = "integer" | "Boolean"
  12. VariableList = VariableName { "," VariableName } .
  13. ProcedureDefinition = "proc"  ProcedureName Block .
  14. StatementPart = { Statement ";" } .
  15. Statement =
  16.    EmptyStatement | ReadStatement | WriteStatement |
  17.    AssignmentStatement | ProcedureStatement |
  18.    IfStatement | DoStatement .
  19. EmptyStatement = "skip" .
  20. ReadStatement = "read" VariableAccessList .
  21. VariableAccessList = VariableAccess {"," VariableAccess } .
  22. WriteStatement = "write" ExpressionList .
  23. ExpressionList = Expression {"," Expression } .
  24. AssignmentStatement = 
  25.    VariableAccessList ":=" ExpressionList .
  26. ProcedureStatement = "call" ProcedureName .
  27. IfStatement = "if" GuardedCommandList "fi" .
  28. DoStatement = "do" GuardedCommandList "od" .
  29. GuardedCommandList =
  30.    GuardedCommand { "[]" GuardedCommand } .
  31. GuardedCommand = Expression "->" StatementPart .
  32. Expression = PrimaryExpression 
  33.    { PrimaryOperator PrimaryExpression } .
  34. PrimaryOperator = "&" | "|" .
  35. PrimaryExpression = SimpleExpression
  36.    [ RelationalOperator SimpleExpression ] .
  37. RelationalOperator = "<" | "=" | ">" .
  38. SimpleExpression =
  39.    [ "-" ] Term { AddingOperator Term } .
  40. AddingOperator = "+" | "-" .
  41. Term = Factor { MultiplyingOperator Factor } .
  42. MultiplyingOperator = "*" | "/" | "\" .
  43. Factor = Constant | VariableAccess | 
  44.    "(" Expression ")" | "~" Factor .
  45. VariableAccess = VariableName [ IndexedSelector ] .
  46. IndexedSelector = "[" Expression "]" .
  47. Constant = Numeral | BooleanSymbol | ConstantName .
  48. Numeral = Digit { Digit } .
  49. BooleanSymbol = "false" | "true" .
  50. Name = Letter { Letter | Digit | "_" } .
  51.