|
|
1.1 root 1: \chapter{Syntax of the full language}
2: \label{grammar}
3: {\samepage
4: \renewcommand{\lhs}[1]{\pagebreak[1] \\ \vspace{2ex}
5: #1 \ \( \rightarrow \) \' }
6: \newcommand{\also}[0]{\nopagebreak[3] \\}
7: \begin{tabbing}
8: longword \( \rightarrow \) \= \{ lab = exp , \rep{0} , lab = exp \} \
9: \ \ \ \= \kill
10: \+
11: \lhs{ide} ID \> {\em symbolic or alphabetic}
12: \also \verb"*" \> {\em \verb"*" is legal as a value-identifer}
13: \also = \> {\em \verb"=" may be used but not rebound }
14: \lhs{opid} ide \>
15: \also \res{op} ide \> {\em removes infix status }
16: \lhs{qualid} ide
17: \also ID . qualid
18: \lhs{ident} opid
19: \also qualid
20: \lhs{lab} ID \>
21: \also INT \> {\em numeric labels}
22: \lhs{const} INT \>
23: \also REAL \>
24: \also STRING \>
25: \also () \>
26: \also ident \> {\em nullary constructor}
27: \lhs{exp} ident \> {\em variable}
28: \also const
29: \also \# lab \> {\em field selector }
30: \also \{ lab = exp , \rep{0} , lab = exp \} \> {\em record}
31: \also ( exp , \rep{2} , exp ) \> {\em tuple }
32: \also ( exp ; \rep{1} ; exp ) \> {\em sequence }
33: \also \verb"[" exp , \rep{0} , exp \verb"]" \> {\em list}
34: \also \res{let} decs \res{in} expseq \res{end} \> {\em local
35: declaration}
36: \also exp exp \> {\em application; left--associative}
37: \also exp ide exp \>{\em infixed application}
38: \also exp : ty \>{\em type constraint}
39: \also exp \res{andalso} exp \>{\em conjunction}
40: \also exp \res{orelse} exp \>{\em disjunction}
41: \also \res{fn} match \>{\em function}
42: \also \res{case} exp \res{of} match \>{\em case expression}
43: \also \res{while} exp \res{do} exp \>{\em iteration}
44: \also \res{if} exp \res{then} exp \res{else} exp \>{\em conditional}
45: \also exp \res{handle} match \>{\em handle exception; right--associative}
46: \also \res{raise} exp \>{\em raise exception}
47: \lhs{match} pat \verb"=>" exp $\mid$ \rep{1} $\mid$ pat \verb"=>" exp \>
48: \lhs{apat} ident \>{\em variable binding }
49: \also const \>{\em constant pattern}
50: \also \verb"_" \>{\em wildcard}
51: \also ( pat )
52: \also ( pat , \rep{2} , pat) \>{\em tuple}
53: \also \{ patfield , \rep{0} , patfield \} \>{\em record}
54: \also \{ patfield , \rep{0} , patfield , ... \} \>{\em flexible record}
55: \also \verb"[" pat , \rep{0} , pat \verb"]" \>{\em list}
56: \lhs{pat} apat \>{\em atomic}
57: \also ident apat \>{\em construction; left--associative}
58: \also pat ide pat \>{\em infixed construction}
59: \also pat : ty \>{\em type constraint}
60: \also opid constraint \res{as} pat \>{\em layered}
61: \lhs{patfield} lab = pat \>{\em normal}
62: \also ID \>{\em abbreviation}
63: \also ID \res{as} pat \>{\em abbreviation}
64: \lhs{ty} \res{tyvar} \>{\em type variable}
65: \also \{ lab : ty , \rep{0} , lab : ty \} \>{\em record type}
66: \also ( ty )
67: \also ( ty , \rep{2} , ty ) qualid \>{\em type construction}
68: \also ty qualid \>{\em unary type construction}
69: \also qualid \>{\em nullary type construction}
70: \also ty \verb"*" \rep{2} \verb"*" ty \>{\em typle type}
71: \also ty \verb"->" ty \>{\em function type; right--associative}
72: \lhs{vb} pat = exp \>{\em simple }
73: \also vb \res{and} \rep{1} \res{and} vb \>{\em multiple}
74: \lhs{constraint} \> {\em absent}
75: \also : ty \>{\em type constraint}
76: \lhs{rvb} opid constraint = \res{fn} match \>{\em simple recursive}
77: \also rvb \res{and} \rep{1} \res{and} rvb \>{\em mutually recursive}
78: \lhs{clause} opid apat \rep{1} apat constraint = exp \>{\em prefix}
79: \also pat ide pat constraint = exp \>{\em infix}
80: \lhs{fb} clause $\mid$ \rep{1} $\mid$ clause \>{\em clausal function}
81: \also fb \res{and} \rep{1} \res{and} fb \>{\em mutually recursive}
82: \lhs{tb} tyvars ID = ty \>{\em simple }
83: \also tb \res{and} \rep{1} \res{and} tb \>{\em multiple}
84: \lhs{tyvars} \> {\it absent}
85: \also \res{tyvar} \>{\em single}
86: \also ( \res{tyvar} , \rep{2} , \res{tyvar} ) \>{\em multiple}
87: \lhs{db} tyvars ID = constr $\mid$ \rep{1} $\mid$ constr \>{\em
88: simple}
89: \also db \res{and} \rep{1} \res{and} db \>{\em mutually recursive}
90: \lhs{constr} opid \>{\em nullary (constant)}
91: \also opid \res{of} ty \>{\em unary}
92: \lhs{eb} ide \>{\em nullary (constant)}
93: \also ide \res{of} ty \>{\em unary}
94: \also ide = qualid \>{\em re--naming}
95: \also eb \res{and} \rep{1} \res{and} eb \>{\em multiple}
96: \lhs{ldec} \res{val} vb \>{\em value declaration}
97: \also \res{val} \res{rec} rvb \>{\em recursive value declaration}
98: \also \res{fun} fb \>{\em function declaration}
99: \also \res{type} tb \>{\em type declaration}
100: \also \res{datatype} db \>{\em datatype declaration}
101: \also \res{exception} eb \>{\em exception declaration}
102: \also \res{local} ldec \res{in} ldec \res{end} \>{\em local
103: declaration}
104: \also \res{open} qualid \rep{1} qualid \>{\em structure visibility}
105: \also fixity ide \rep{1} ide \>{\em directive}
106: \also ldec ldec \>{\em declaration sequence}
107: \also ldec \verb";" \>{\em optional semicolon}
108: \lhs{fixity} \res{infix} INT \>{\em declare infix,
109: left--associative}
110: \also \res{infix} \>{\em declare infix, precedence 0}
111: \also \res{infixr} INT \>{\em infix, right associative}
112: \also \res{infixr} \>{\em infix, right assoc., prec. 0}
113: \also \res{nonfix} \>{\em cancel infix status}
114: \lhs{sgn} ID
115: \also \res{sig} specs \res{end}
116: \lhs{specs} spec
117: \also specs spec
118: \also specs ;
119: \lhs{spec} \res{structure} ID : sgn \res{and} \rep{1} \res{and} ID : sgn
120: \also \res{datatype} db \res{and} \rep{1} \res{and} db
121: \also \res{type} tyvars ID \res{and} \rep{1} \res{and} tyvars ID
122: \also \res{val} ide : ty \res{and} \rep{1} \res{and} ide : ty
123: \also \res{exception} exnspec \res{and} \rep{1} \res{and} exnspec
124: \also \res{sharing} sharspec \res{and} \rep{1} \res{and} sharspec
125: \lhs{exnspec} ide
126: \also ide \res{of} ty
127: \lhs{sharspec} qualid = \rep{2} = qualid
128: \end{tabbing}
129: This description is at present incomplete, as it is missing the
130: grammar rules for structures and functors.
131: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.