home *** CD-ROM | disk | FTP | other *** search
- This is the Backus-Naur form of PL:
-
- Program = Block ".".
- Block = "begin" DefinitionPart StatementPart "end".
- DefinitionPart = { Definition ";" }.
- Definition = ConstantDefinition | VariableDefinition |
- ProcedureDefinition .
- ConstantDefinition = "const" ConstantName "=" Constant .
- VariableDefinition = TypeSymbol VariableList |
- TypeSymbol "array" VariableList "[" Constant "]" .
- TypeSymbol = "integer" | "Boolean"
- VariableList = VariableName { "," VariableName } .
- ProcedureDefinition = "proc" ProcedureName Block .
- StatementPart = { Statement ";" } .
- Statement =
- EmptyStatement | ReadStatement | WriteStatement |
- AssignmentStatement | ProcedureStatement |
- IfStatement | DoStatement .
- EmptyStatement = "skip" .
- ReadStatement = "read" VariableAccessList .
- VariableAccessList = VariableAccess {"," VariableAccess } .
- WriteStatement = "write" ExpressionList .
- ExpressionList = Expression {"," Expression } .
- AssignmentStatement =
- VariableAccessList ":=" ExpressionList .
- ProcedureStatement = "call" ProcedureName .
- IfStatement = "if" GuardedCommandList "fi" .
- DoStatement = "do" GuardedCommandList "od" .
- GuardedCommandList =
- GuardedCommand { "[]" GuardedCommand } .
- GuardedCommand = Expression "->" StatementPart .
- Expression = PrimaryExpression
- { PrimaryOperator PrimaryExpression } .
- PrimaryOperator = "&" | "|" .
- PrimaryExpression = SimpleExpression
- [ RelationalOperator SimpleExpression ] .
- RelationalOperator = "<" | "=" | ">" .
- SimpleExpression =
- [ "-" ] Term { AddingOperator Term } .
- AddingOperator = "+" | "-" .
- Term = Factor { MultiplyingOperator Factor } .
- MultiplyingOperator = "*" | "/" | "\" .
- Factor = Constant | VariableAccess |
- "(" Expression ")" | "~" Factor .
- VariableAccess = VariableName [ IndexedSelector ] .
- IndexedSelector = "[" Expression "]" .
- Constant = Numeral | BooleanSymbol | ConstantName .
- Numeral = Digit { Digit } .
- BooleanSymbol = "false" | "true" .
- Name = Letter { Letter | Digit | "_" } .
-