@@ -58,13 +58,12 @@ const generate = (cb) => {
58
58
Object . keys ( properties ) . map ( key => p . property ( properties [ key ] , key ) ) ;
59
59
60
60
const {
61
- scopeIdentifierSpan,
61
+ // scopeIdentifierSpan,
62
62
varSizeSpan, varIdSpan, varNameSpan,
63
63
idSpan,
64
64
commandSpan,
65
65
timeSpan
66
66
} = `
67
- scopeIdentifierSpan
68
67
varSizeSpan varIdSpan varNameSpan
69
68
idSpan
70
69
commandSpan
@@ -73,10 +72,12 @@ const generate = (cb) => {
73
72
. trim ( ) . split ( / \s + / )
74
73
. reduce ( ( res , n ) => Object . assign ( res , { [ n ] : p . span ( p . code . span ( n ) ) } ) , { } ) ;
75
74
75
+ // scopeIdentifierSpan
76
+
76
77
const {
77
78
declaration,
78
- scopeType, scopeTypeEnd,
79
- scopeIdentifier, scopeIdentifierEnd,
79
+ // scopeType, scopeTypeEnd,
80
+ // scopeIdentifier, scopeIdentifierEnd,
80
81
varType, varTypeEnd,
81
82
varSize, varSizeEnd,
82
83
varId, varIdEnd,
@@ -89,8 +90,6 @@ const generate = (cb) => {
89
90
simulationId
90
91
} = `
91
92
declaration
92
- scopeType scopeTypeEnd
93
- scopeIdentifier scopeIdentifierEnd
94
93
varType varTypeEnd
95
94
varSize varSizeEnd
96
95
varId varIdEnd
@@ -105,6 +104,9 @@ const generate = (cb) => {
105
104
. trim ( ) . split ( / \s + / )
106
105
. reduce ( ( res , n ) => Object . assign ( res , { [ n ] : p . node ( n ) } ) , { } ) ;
107
106
107
+ // scopeType scopeTypeEnd
108
+ // scopeIdentifier scopeIdentifierEnd
109
+
108
110
const enddefinitions = p . node ( 'inDeclarationEnd' ) ;
109
111
110
112
const cmd = objection ( {
@@ -134,56 +136,50 @@ const generate = (cb) => {
134
136
135
137
declaration
136
138
. match ( spaces , declaration )
137
- . select ( cmd ( '$scope' ) ,
138
- p . invoke ( p . code . store ( 'command' ) , commandSpan . start ( scopeType ) ) )
139
- . select ( cmd ( '$var' ) ,
140
- p . invoke ( p . code . store ( 'command' ) , commandSpan . start ( varType ) ) )
141
- . select ( cmd ( '$comment $date $timescale $upscope $version' ) ,
139
+ // .select(cmd('$scope'),
140
+ // p.invoke(p.code.store('command'), commandSpan.start(scopeType)))
141
+ // .select(cmd('$var'),
142
+ // p.invoke(p.code.store('command'), commandSpan.start(varType)))
143
+ . select ( cmd ( '$scope $var $upscope $ comment $date $timescale $version' ) ,
142
144
p . invoke ( p . code . store ( 'command' ) , commandSpan . start ( inDeclaration ) ) )
143
145
. select ( cmd ( '$enddefinitions' ) ,
144
146
p . invoke ( p . code . store ( 'command' ) , commandSpan . start ( enddefinitions ) ) )
145
147
. otherwise ( p . error ( 1 , 'Expected declaration command' ) ) ;
146
148
147
- // $scope
148
-
149
- scopeType
150
- . match ( spaces , scopeType )
151
- . otherwise ( scopeTypeEnd ) ;
152
-
153
- scopeTypeEnd
154
- . select (
155
- {
156
- module : 0 ,
157
- task : 1 ,
158
- function : 2 ,
159
- begin : 3 ,
160
- fork : 4 ,
161
- // extra scopes from Verilator
162
- generate : 5 ,
163
- struct : 6 ,
164
- union : 7 ,
165
- class : 8 ,
166
- interface : 9 ,
167
- package : 10 ,
168
- program : 11
169
- } ,
170
- p . invoke ( p . code . store ( 'type' ) , scopeIdentifier ) )
171
- . otherwise ( p . error ( 2 , 'Expected scope type' ) ) ;
172
-
173
- scopeIdentifier
174
- . match ( spaces , scopeIdentifier )
175
- . otherwise ( scopeIdentifierSpan . start ( scopeIdentifierEnd ) ) ;
176
-
177
- scopeIdentifierEnd
178
- . match ( spaces , scopeIdentifierSpan . end ( inDeclaration ) )
179
- . skipTo ( scopeIdentifierEnd ) ;
180
-
181
- // $var
182
-
183
- varType
184
- . match ( spaces , varType )
185
- . otherwise ( varTypeEnd ) ;
186
-
149
+ // $scope module clkdiv2n_tb $end
150
+ // ^^^^^^
151
+
152
+ // scopeType.match(spaces, scopeType).otherwise(scopeTypeEnd);
153
+ // scopeTypeEnd
154
+ // .select(
155
+ // {
156
+ // module: 0,
157
+ // task: 1,
158
+ // function: 2,
159
+ // begin: 3,
160
+ // fork: 4,
161
+ // // extra scopes from Verilator
162
+ // generate: 5,
163
+ // struct: 6,
164
+ // union: 7,
165
+ // class: 8,
166
+ // interface: 9,
167
+ // package: 10,
168
+ // program: 11
169
+ // },
170
+ // p.invoke(p.code.store('type'), scopeIdentifier))
171
+ // .otherwise(p.error(2, 'Expected scope type'));
172
+
173
+ // $scope module clkdiv2n_tb $end
174
+ // ^^^^^^^^^^^
175
+
176
+ // scopeIdentifier.match(spaces, scopeIdentifier).otherwise(scopeIdentifierSpan.start(scopeIdentifierEnd));
177
+ // scopeIdentifierEnd.match(spaces, scopeIdentifierSpan.end(inDeclaration)).skipTo(scopeIdentifierEnd);
178
+
179
+ // $var reg 3 ( r_reg [2:0] $end
180
+ // ^^^
181
+
182
+ varType . match ( spaces , varType ) . otherwise ( varTypeEnd ) ;
187
183
varTypeEnd
188
184
. select ( {
189
185
event : 1 ,
@@ -207,29 +203,23 @@ const generate = (cb) => {
207
203
} , p . invoke ( p . code . store ( 'type' ) , varSize ) )
208
204
. otherwise ( p . error ( 3 , 'Expected var type' ) ) ;
209
205
210
- varSize
211
- . match ( spaces , varSize )
212
- . otherwise ( varSizeSpan . start ( varSizeEnd ) ) ;
206
+ // $var reg 3 ( r_reg [2:0] $end
207
+ // ^
213
208
214
- varSizeEnd
215
- . match ( spaces , varSizeSpan . end ( varId ) )
216
- . skipTo ( varSizeEnd ) ;
209
+ varSize . match ( spaces , varSize ) . otherwise ( varSizeSpan . start ( varSizeEnd ) ) ;
210
+ varSizeEnd . match ( spaces , varSizeSpan . end ( varId ) ) . skipTo ( varSizeEnd ) ;
217
211
218
- varId
219
- . match ( spaces , varId )
220
- . otherwise ( varIdSpan . start ( varIdEnd ) ) ;
212
+ // $var reg 3 ( r_reg [2:0] $end
213
+ // ^
221
214
222
- varIdEnd
223
- . match ( spaces , varIdSpan . end ( varName ) )
224
- . skipTo ( varIdEnd ) ;
215
+ varId . match ( spaces , varId ) . otherwise ( varIdSpan . start ( varIdEnd ) ) ;
216
+ varIdEnd . match ( spaces , varIdSpan . end ( varName ) ) . skipTo ( varIdEnd ) ;
225
217
226
- varName
227
- . match ( spaces , varName )
228
- . otherwise ( varNameSpan . start ( varNameEnd ) ) ;
218
+ // $var reg 3 ( r_reg [2:0] $end
219
+ // ^^^^^
229
220
230
- varNameEnd
231
- . match ( spaces , varNameSpan . end ( inDeclaration ) )
232
- . skipTo ( varNameEnd ) ;
221
+ varName . match ( spaces , varName ) . otherwise ( varNameSpan . start ( varNameEnd ) ) ;
222
+ varNameEnd . match ( '$end' , commandSpan . end ( varNameSpan . end ( declaration ) ) ) . skipTo ( varNameEnd ) ;
233
223
234
224
// $end
235
225
0 commit comments