Pascal - Syntax in EBNF Notation MetaSyntax: [ X ] 0 or 1 Occurrences of X { X } No or any Number of X X | Y X or Y 'x' x is Character in Source ( ) , { }, [ ] work as Parenthesis pascal-program: ['program' identifier ;] block '.' identifier-list: identifier {',' identifier } block: { declaration } 'begin' statement-list 'end' declaration: constant-declaration | type-declaration | variable-declaration | proc-declaration | func-declaration | label-declaration label-declaration: 'label' unsignedinteger { ',' unsignedinteger } ';' constant-declaration: 'const' identifier '=' constant ';'{ identifier '=' constant ';' } type-declaration: 'type' identifier = type ';' { identifier = type ' ';' } variable-declaration: 'var' identifier { ',' identifier } ':' type constant: expression // Value fix at Compiletime type: simple-type | real-type | structured-type | '^' typeid simple-type: '(' identifier { ',' identifier } ')' | constant '..' constant | typeid structured-type: 'array' '[' index-list ']' 'of' type | 'record' field-list 'end' | 'set' 'of' simple-type | 'file' 'of' type index-list: simple-type { ',' simple-type } field-list: fixed-part | fixed-part ';' variant-part | variant-part fixed-part: record-field { '; record-field } record-field: empty | identifier { ',' identifier } ':' type variant-part: 'case' tag-field 'of' variant-list tag-field: typeid | identifier ':' typeid variant-list: variant { ';' variant } variant: empty | constant { ',' constant } ':' '(' field-list ')' proc-declaration: 'procedure' identifier [ '(' formal-parameter-list ')' ] ';' block-or-forward ';' func-declaration: 'function' identifier [ '(' formal-parameter-list ')' ] ':' typeid ';' block-or-forward ';' block-or-forward: block | 'forward' formal-parameter-list: formal-parameter { ';' formal-parameter } formal-parameter: [ 'var' ] identifier { ',' identifier } ':' typeid | 'procedure' identifier [ parameters ] | 'function' identifier [ parameters ] ':' typeid statement-list: statement { ';' statement } statement: empty | variable ':=' expression | 'begin' statement-list 'end' | 'if' expression 'then' statement [ 'else' statement ] | 'case' expression 'of' case-list 'end' | 'while' expression 'do' statement | 'repeat' statement-list 'until' expression | 'for' varid ':=' expression ( 'to' | 'downto' ) expression 'do' statement | procid [ '(' expression-list ')' ] | 'goto' label | 'with' variablelist 'do' statement | label ':' statement variable: identifier { '[' expression-list ']' | '.' fieldid | '^' } expression-list: expression { ',' expression } case-list: { case-label-list':' statement ';' } [ 'else' statement ] case-label-list: case-label { ',' case-label } case-label: constant [ '..' constant ] label: unsigned-integer variable-list: variable { ',' variable } expression: additive-expression { relational-op additive-expression } relational-op: '<' | '<=' | '=' | '<>' | '=>' | '>' additive-expression: multiplicative-expression { additive-op multiplicative-expression } additive-op: '+' | '-' | 'or' multiplicative-expression: unary-expression { multiplicative-op unary-expression } multiplicative-op: '*' | '/' | 'div' | 'mod' | 'and' | 'in' unary-expression: { unary-op } primary-expression unary-op: '+' | '-' | 'not' primary-expression: variable | unsigned-integer | unsigned-real | string | 'nil' | funcid '(' expression-list ')' | '[' element-list ']' | '(' expression ')' element-list: empty | element { ',' element } element: expression | expression '..' expression constid: identifier // declared as const typeid: identifier // declared as type funcid: identifier // declared as func procid: identifier // declared as proc fieldid: identifier // declared as record-field varid: identifier // declared as var empty: