Skip to content

WebDSL-Lexical.sdf3

pdmosses/webdsl-statix/webdslstatix/syntax/WebDSL-Lexical.sdf3

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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
module 

lexical sorts

   TemplateId VarId FAVarId FunId     

lexical syntax

   = Id
   = QId "." Id
  TemplateId = Id %% hook for reject rules on templatecall names
  VarId = Id
  FAVarId = VarId
  FunId = Id
   = Id
   = [a-zA-Z] [a-zA-Z0-9\_]*
   = [a-zA-Z] [a-zA-Z0-9\_\-]*
   = [a-zA-Z0-9\_\.] [a-zA-Z0-9\-\_\.]*
   = ~[\n\r]*

context-free sorts

   ModulePart ImportName OptWildcardImport

context-free syntax

  ModulePart.ModulePart = <<ExtendedId>>
  OptWildcardImport.WildcardImport = "/-"
  OptWildcardImport.NoWildcardImport = <>

syntax

  -CF.ModuleName = { ModulePart-CF "/"}+
  ImportName-CF.ImportName = ModuleName-CF OptWildcardImport-CF

lexical restrictions

  Id -/- [a-zA-Z0-9\_]
  PageId -/- [a-zA-Z0-9\_\-]
  ModuleName -/- [a-zA-Z0-9\/]

lexical sorts

    Long   ExponentPart 

lexical syntax

   = "-"? [0-9]+
  Long = "-"? [0-9]+ "L"
   = "-"? FloatDigits ExponentPart? [fFdD]?
   = [0-9]* "." [0-9]+
   = [0-9]+
  ExponentPart = [eE] SignedInteger
   = [\+\-]? [0-9]+
   = "-"? [0-9]+ {reject}
   = "." {reject}

lexical restrictions

  Int -/- [0-9]
  Int -/- [L]             // to avoid longs getting parsed as an integer followed by a template call
  Int -/- [eEfFdD]        // to avoid floats getting parsed as an integer followed by a template call
  Float -/- [fFdD]
  FloatDigits -/- [0-9]
  SignedInteger -/- [0-9]

context-free sorts

   StringPart 

%% Kernel syntax is required here since we do not want LAYOUT to be parsed between
%% the first QMLex and StringLex
syntax

  -CF.String = "\"" StringPart-CF* "\""

  StringPart-CF.StringValue = StringLex-LEX
  StringPart-CF.InterpValue = "~" StringInterpExp-CF

  -CF.InterpSimpleExp = SimpleExp-CF

context-free restrictions

  StringInterpExp -/- [\.\(]

context-free sorts

  OutputShorthand

context-free syntax
%% ~SimpleExp and ~(Exp) shorthand for output template call

  OutputShorthand.OutputShorthandSimpleExp = "~" SimpleExp

context-free sorts

  

context-free syntax
%% SimpleExp: specific commonly occuring expressions allowed directly after '~' inside string
%% allowing all expressions directly after '~' causes too many ambiguities
%% parentheses expression is used as delimiter for inserting any expression
%% allowed after '~': var/fieldaccess/thiscall/call/brackets a, a.b, a(), a.b(), (exp)
%% a '.' after a SimpleExp must be rejected as part of String to avoid amb, e.g. not allowed: "~a."
%% in these cases, use '()' if a '.' is needed as part of the string,       e.g.     allowed: "~(a)."

  .SimpleVar = Id
  .SimpleFieldAccess = <<SimpleExp> . <PropertyId>>

lexical sorts

  QMLex  StringChar 

lexical syntax

  QMLex = "\""
   = StringChar+
  StringChar = ~[\"\n\~\\]
  StringChar = "\\" [0-9btnfr\'\"\\\~]
   = [0-9a-fA-F]
  StringChar = "\\u" HexPart HexPart HexPart HexPart

lexical restrictions

  StringLex -/- ~[\"\n\~]

lexical sorts

  InsideComment  NewLineEOF 

lexical syntax
  LAYOUT     = [\ \t\n\r]
  LAYOUT     = "//" ~[\n\r]* NewLineEOF
  LAYOUT     = "/*" InsideComment* "*/"
  InsideComment  = ~[\*]
  InsideComment  = CommentChar
      = [\*]
  NewLineEOF = [\n\r]
  NewLineEOF = EOF
          =

lexical restrictions
  CommentChar -/- [\/]
  EOF         -/- ~[]

context-free restrictions

  LAYOUT? -/- [\ \t\n\r]
  LAYOUT? -/- [\/].[\/]
  LAYOUT? -/- [\/].[\*]
  SectionName -/- ~[\n\r]

lexical sorts

  

lexical syntax

   = ~[\ \t\n\r\}]+

lexical restrictions

  Word -/- ~[\ \t\n\r\}]

lexical sorts

   GenericSortLex

lexical syntax

   = [A-Z] [a-zA-Z0-9\_]*
  GenericSortLex = Id
  GenericSortLex = "Ref" {reject}

lexical restrictions

  SimpleSortLex -/- [a-zA-Z0-9\_]