Intermezzo:
An elementary symbol is:
Li l “ b ”
– Literal: “abc” – Sort (non-terminal) nam – Character classes: [a-z]:
- ~: complement of charac
p
- /: difference of two char
/\: intersection of two ch
- /\: intersection of two ch
- \/: union of two charact
Introduction
Symbols (1)
mes: INT : one of a, b, ..., z
cter class. racter classes. haracter classes haracter classes. er classes.
to ASF+SDF 1
Intermezzo:
A complex symbol is: A complex symbol is:
– Repetition:
- S* zero or more times S
- {S1 S2}* zero or more
- {S1 S2}
zero or more
- {S1 S2}+ one or more t
O ti l S?
– Optional: S? zero or one – Alternative: S | T an S o
– Tuple: <S,T> shorthand f
– Parameterized sorts: S[[
Introduction
Symbols (2)
S; S+ one or more times S
times S1 separated by S2 times S1 separated by S2 times S1 separated by S2
f S e occurrences of S
- r a T
for “<” S “,” T “>”
[ P1, P2 ]]
to ASF+SDF 2
Intermezzo: produ
- General form of a produ
1 2
– S1 S2 ... Sn -> S0 Attr
- Lexical syntax and context-
– Between the symbols in
symbols may occur in th
– A context-free productio
- S1 LAYOUT? S2 LAY
- S1 LAYOUT? S2 LAY
Introduction
uctions (functions)
uction (function):
b ributes
- free syntax are similar, but
a production optional layout he input text.
- n is equivalent with:
YOUT? LAYOUT? Sn -> S0 YOUT? ... LAYOUT? Sn S0
to ASF+SDF 3
Example: floatin
sorts UnsignedInt SignedInt Unsig lexical syntax [0] | ([1-9][0-9]*) [\+\-]? UnsignedInt [\ \ ]? UnsignedInt UnsignedInt "." [0-9]+ ([eE] Sig Unsi n dInt [ E] Si n dInt UnsignedInt [eE] SignedInt UnsignedInt | UnsignedReal 0 1 14 0.1 3e4 3.014e-7
Introduction
ng point numbers
gnedReal Number
- > UnsignedInt
- > SignedInt
SignedInt gnedInt)? -> UnsignedReal > Unsi n dR l
- > UnsignedReal
- > Number
00 01 04.1 3e04 3.14e-07
to ASF+SDF 4