File: oberon.atg

package info (click to toggle)
pm3 1.1.15-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 140,404 kB
  • ctags: 106,859
  • sloc: ansic: 891,434; modula3: 550,649; exp: 18,409; sh: 16,930; lisp: 13,693; makefile: 13,271; asm: 11,795; cpp: 5,560; yacc: 5,125; sed: 1,047; csh: 254; awk: 223; pascal: 95; fortran: 5
file content (93 lines) | stat: -rw-r--r-- 4,645 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
COMPILER Oberon
(* A grammar for Oberon *)

CHARACTERS
  eol      = CHR(13) .
  letter   = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" .
  digit    = "0123456789" .
  hexDigit = digit + "ABCDEF" .
  noQuote  = ANY - '"' - eol  .

IGNORE  CHR(9) .. CHR(13)

COMMENTS
  FROM "(*" TO "*)" NESTED

TOKENS
  ident   =  letter { letter | digit } .
  integer  =  digit { digit } | digit { hexDigit } "H" .
  real  =  digit { digit } "." { digit }
           [ ("E" | "D") [ "+" | "-" ] digit { digit } ] .
  CharConstant = digit { hexDigit } "X" .
  string  =  '"' { noQuote } '"' .

PRODUCTIONS
  Oberon           =  module .
  number           =  integer | real .
  identdef         =  ident [ "*" ] .
  qualident        =  [ ident "." ] ident .
  ConstantDeclaration  =  identdef "=" ConstExpression .
  ConstExpression  =  expression .
  TypeDeclaration  =  identdef "=" type .
  type             =  qualident | ArrayType | RecordType | PointerType | ProcedureType .
  ArrayType        =  "ARRAY" length { "," length } "OF" type .
  length           =  ConstExpression .
  RecordType       =  "RECORD" [ "(" BaseType ")" ] FieldListSequence "END" .
  BaseType         =  qualident .
  FieldListSequence  =  FieldList { ";" FieldList } .
  FieldList        =  [ IdentList ":" type ] .
  IdentList        =  identdef { "," identdef } .
  PointerType      =  "POINTER" "TO" type .
  ProcedureType    =  "PROCEDURE" [ FormalParameters ] .
  VariableDeclaration  =  IdentList ":" type .
  designator       =  qualident { "." ident | "[" ExpList "]" | "(" qualident ")" | "^"  } .
  ExpList          =  expression { "," expression } .
  expression       =  SimpleExpression [ relation SimpleExpression ] .
  relation         =  "=" | "#" | "<" | "<=" | ">" | ">=" | "IN" | "IS" .
  SimpleExpression =  [ "+" | "-" ] term { AddOperator term } .
  AddOperator      =  "+" | "-" | "OR" .
  term             =  factor { MulOperator factor } .
  MulOperator      =  "*" | "/" | "DIV" | "MOD" | "&" .
  factor           =  number | CharConstant | string | "NIL" | set
                      | designator [ ActualParameters ]
                      | "(" expression ")" | "~" factor .
  set              =  "{" [ element { "," element } ] "}" .
  element          =  expression [ ".." expression ] .
  ActualParameters =  "(" [ ExpList ] ")" .
  statement        =  [ assignment | ProcedureCall | IfStatement |
                        CaseStatement | WhileStatement | RepeatStatement |
                        LoopStatement | WithStatement | "EXIT" |
                        "RETURN" [ expression ] ] .
  assignment       =  designator ":=" expression .
  ProcedureCall    =  designator [ ActualParameters ] .
  StatementSequence =  statement { ";" statement } .
  IfStatement      =  "IF" expression "THEN" StatementSequence
                     { "ELSIF" expression "THEN" StatementSequence }
                     [ "ELSE" StatementSequence ] "END" .
  CaseStatement    =  "CASE" expression "OF" case { "|" case }
                     [ "ELSE" StatementSequence ] "END" .
  case             =  [ CaseLabelList ":" StatementSequence ] .
  CaseLabelList    =  CaseLabels { "," CaseLabels } .
  CaseLabels       =  ConstExpression [ ".." ConstExpression ] .
  WhileStatement   =  "WHILE" expression "DO" StatementSequence "END" .
  RepeatStatement  =  "REPEAT" StatementSequence "UNTIL" expression .
  LoopStatement    =  "LOOP" StatementSequence "END" .
  WithStatement    =  "WITH" qualident ":" qualident "DO" StatementSequence "END" .
  ProcedureDeclaration  =  ProcedureHeading ";" ProcedureBody ident .
  ProcedureHeading =  "PROCEDURE" [ "*" ] identdef [ FormalParameters ] .
  ProcedureBody    =  DeclarationSequence [ "BEGIN" StatementSequence ] "END" .
  ForwardDeclaration  =  "PROCEDURE" "^" ident [ "*" ] [ FormalParameters ] .
  DeclarationSequence  =  {   "CONST" { ConstantDeclaration ";" }
                            | "TYPE"  { TypeDeclaration ";" }
                            | "VAR"   { VariableDeclaration ";" } }
                          {   ProcedureDeclaration ";"
                            | ForwardDeclaration ";" } .
  FormalParameters =  "(" [ FPSection { ";" FPSection } ] ")" [ ":" qualident ] .
  FPSection        =  [ "VAR" ] ident { "," ident } ":" FormalType .
  FormalType       =  { "ARRAY" "OF" } (qualident | ProcedureType) .
  ImportList       =  "IMPORT" import { "," import } ";" .
  import           =  ident [ ":=" ident ] .
  module           =  "MODULE" ident ";"
                      [ ImportList ] DeclarationSequence
                      [ "BEGIN" StatementSequence ] "END" ident "." .
END Oberon.