1use crate::*;
2
3#[tracable_parser]
6#[packrat_parser]
7pub(crate) fn concurrent_assertion_item(s: Span) -> IResult<Span, ConcurrentAssertionItem> {
8 alt((
9 concurrent_assertion_item_statement,
10 map(checker_instantiation, |x| {
11 ConcurrentAssertionItem::CheckerInstantiation(Box::new(x))
12 }),
13 ))(s)
14}
15
16#[tracable_parser]
17#[packrat_parser]
18pub(crate) fn concurrent_assertion_item_statement(
19 s: Span,
20) -> IResult<Span, ConcurrentAssertionItem> {
21 let (s, a) = opt(pair(block_identifier, symbol(":")))(s)?;
22 let (s, b) = concurrent_assertion_statement(s)?;
23 Ok((
24 s,
25 ConcurrentAssertionItem::Statement(Box::new(ConcurrentAssertionItemStatement {
26 nodes: (a, b),
27 })),
28 ))
29}
30
31#[tracable_parser]
32#[packrat_parser]
33pub(crate) fn concurrent_assertion_statement(
34 s: Span,
35) -> IResult<Span, ConcurrentAssertionStatement> {
36 alt((
37 map(assert_property_statement, |x| {
38 ConcurrentAssertionStatement::AssertPropertyStatement(Box::new(x))
39 }),
40 map(assume_property_statement, |x| {
41 ConcurrentAssertionStatement::AssumePropertyStatement(Box::new(x))
42 }),
43 map(cover_property_statement, |x| {
44 ConcurrentAssertionStatement::CoverPropertyStatement(Box::new(x))
45 }),
46 map(cover_sequence_statement, |x| {
47 ConcurrentAssertionStatement::CoverSequenceStatement(Box::new(x))
48 }),
49 map(restrict_property_statement, |x| {
50 ConcurrentAssertionStatement::RestrictPropertyStatement(Box::new(x))
51 }),
52 ))(s)
53}
54
55#[tracable_parser]
56#[packrat_parser]
57pub(crate) fn assert_property_statement(s: Span) -> IResult<Span, AssertPropertyStatement> {
58 let (s, a) = keyword("assert")(s)?;
59 let (s, b) = keyword("property")(s)?;
60 let (s, c) = paren(property_spec)(s)?;
61 let (s, d) = action_block(s)?;
62 Ok((
63 s,
64 AssertPropertyStatement {
65 nodes: (a, b, c, d),
66 },
67 ))
68}
69
70#[tracable_parser]
71#[packrat_parser]
72pub(crate) fn assume_property_statement(s: Span) -> IResult<Span, AssumePropertyStatement> {
73 let (s, a) = keyword("assume")(s)?;
74 let (s, b) = keyword("property")(s)?;
75 let (s, c) = paren(property_spec)(s)?;
76 let (s, d) = action_block(s)?;
77 Ok((
78 s,
79 AssumePropertyStatement {
80 nodes: (a, b, c, d),
81 },
82 ))
83}
84
85#[tracable_parser]
86#[packrat_parser]
87pub(crate) fn cover_property_statement(s: Span) -> IResult<Span, CoverPropertyStatement> {
88 let (s, a) = keyword("cover")(s)?;
89 let (s, b) = keyword("property")(s)?;
90 let (s, c) = paren(property_spec)(s)?;
91 let (s, d) = statement_or_null(s)?;
92 Ok((
93 s,
94 CoverPropertyStatement {
95 nodes: (a, b, c, d),
96 },
97 ))
98}
99
100#[tracable_parser]
101#[packrat_parser]
102pub(crate) fn expect_property_statement(s: Span) -> IResult<Span, ExpectPropertyStatement> {
103 let (s, a) = keyword("expect")(s)?;
104 let (s, b) = paren(property_spec)(s)?;
105 let (s, c) = action_block(s)?;
106 Ok((s, ExpectPropertyStatement { nodes: (a, b, c) }))
107}
108
109#[tracable_parser]
110#[packrat_parser]
111pub(crate) fn cover_sequence_statement(s: Span) -> IResult<Span, CoverSequenceStatement> {
112 let (s, a) = keyword("cover")(s)?;
113 let (s, b) = keyword("sequence")(s)?;
114 let (s, c) = paren(triple(
115 opt(clocking_event),
116 opt(triple(
117 keyword("disable"),
118 keyword("iff"),
119 paren(expression_or_dist),
120 )),
121 sequence_expr,
122 ))(s)?;
123 let (s, d) = statement_or_null(s)?;
124 Ok((
125 s,
126 CoverSequenceStatement {
127 nodes: (a, b, c, d),
128 },
129 ))
130}
131
132#[tracable_parser]
133#[packrat_parser]
134pub(crate) fn restrict_property_statement(s: Span) -> IResult<Span, RestrictPropertyStatement> {
135 let (s, a) = keyword("restrict")(s)?;
136 let (s, b) = keyword("property")(s)?;
137 let (s, c) = paren(property_spec)(s)?;
138 let (s, d) = symbol(";")(s)?;
139 Ok((
140 s,
141 RestrictPropertyStatement {
142 nodes: (a, b, c, d),
143 },
144 ))
145}
146
147#[tracable_parser]
148#[packrat_parser]
149pub(crate) fn property_instance(s: Span) -> IResult<Span, PropertyInstance> {
150 let (s, a) = ps_or_hierarchical_property_identifier(s)?;
151 let (s, b) = opt(paren(opt(property_list_of_arguments)))(s)?;
152 Ok((s, PropertyInstance { nodes: (a, b) }))
153}
154
155#[tracable_parser]
156#[packrat_parser]
157pub(crate) fn property_list_of_arguments(s: Span) -> IResult<Span, PropertyListOfArguments> {
158 alt((
159 property_list_of_arguments_named,
160 property_list_of_arguments_ordered,
161 ))(s)
162}
163
164#[recursive_parser]
165#[tracable_parser]
166#[packrat_parser]
167pub(crate) fn property_list_of_arguments_ordered(
168 s: Span,
169) -> IResult<Span, PropertyListOfArguments> {
170 let (s, a) = list(symbol(","), opt(property_actual_arg))(s)?;
171 let (s, b) = many0(tuple((
172 symbol(","),
173 symbol("."),
174 identifier,
175 paren(opt(property_actual_arg)),
176 )))(s)?;
177 Ok((
178 s,
179 PropertyListOfArguments::Ordered(Box::new(PropertyListOfArgumentsOrdered {
180 nodes: (a, b),
181 })),
182 ))
183}
184
185#[tracable_parser]
186#[packrat_parser]
187pub(crate) fn property_list_of_arguments_named(s: Span) -> IResult<Span, PropertyListOfArguments> {
188 let (s, a) = list(
189 symbol(","),
190 triple(symbol("."), identifier, paren(opt(property_actual_arg))),
191 )(s)?;
192 Ok((
193 s,
194 PropertyListOfArguments::Named(Box::new(PropertyListOfArgumentsNamed { nodes: (a,) })),
195 ))
196}
197
198#[tracable_parser]
199#[packrat_parser]
200pub(crate) fn property_actual_arg(s: Span) -> IResult<Span, PropertyActualArg> {
201 alt((
202 map(property_expr, |x| {
203 PropertyActualArg::PropertyExpr(Box::new(x))
204 }),
205 map(sequence_actual_arg, |x| {
206 PropertyActualArg::SequenceActualArg(Box::new(x))
207 }),
208 ))(s)
209}
210
211#[tracable_parser]
212#[packrat_parser]
213pub(crate) fn assertion_item_declaration(s: Span) -> IResult<Span, AssertionItemDeclaration> {
214 alt((
215 map(property_declaration, |x| {
216 AssertionItemDeclaration::PropertyDeclaration(Box::new(x))
217 }),
218 map(sequence_declaration, |x| {
219 AssertionItemDeclaration::SequenceDeclaration(Box::new(x))
220 }),
221 map(let_declaration, |x| {
222 AssertionItemDeclaration::LetDeclaration(Box::new(x))
223 }),
224 ))(s)
225}
226
227#[tracable_parser]
228#[packrat_parser]
229pub(crate) fn property_declaration(s: Span) -> IResult<Span, PropertyDeclaration> {
230 let (s, a) = keyword("property")(s)?;
231 let (s, b) = property_identifier(s)?;
232 let (s, c) = opt(paren(opt(property_port_list)))(s)?;
233 let (s, d) = symbol(";")(s)?;
234 let (s, e) = many0(assertion_variable_declaration)(s)?;
235 let (s, f) = property_spec(s)?;
236 let (s, g) = opt(symbol(";"))(s)?;
237 let (s, h) = keyword("endproperty")(s)?;
238 let (s, i) = opt(pair(symbol(":"), property_identifier))(s)?;
239 Ok((
240 s,
241 PropertyDeclaration {
242 nodes: (a, b, c, d, e, f, g, h, i),
243 },
244 ))
245}
246
247#[tracable_parser]
248#[packrat_parser]
249pub(crate) fn property_port_list(s: Span) -> IResult<Span, PropertyPortList> {
250 let (s, a) = list(symbol(","), property_port_item)(s)?;
251 Ok((s, PropertyPortList { nodes: (a,) }))
252}
253
254#[tracable_parser]
255#[packrat_parser]
256pub(crate) fn property_port_item(s: Span) -> IResult<Span, PropertyPortItem> {
257 let (s, a) = many0(attribute_instance)(s)?;
258 let (s, b) = opt(pair(keyword("local"), opt(property_lvar_port_direction)))(s)?;
259 let (s, c) = property_formal_type(s)?;
260 let (s, d) = formal_port_identifier(s)?;
261 let (s, e) = many0(variable_dimension)(s)?;
262 let (s, f) = opt(pair(symbol("="), property_actual_arg))(s)?;
263 Ok((
264 s,
265 PropertyPortItem {
266 nodes: (a, b, c, d, e, f),
267 },
268 ))
269}
270
271#[tracable_parser]
272#[packrat_parser]
273pub(crate) fn property_lvar_port_direction(s: Span) -> IResult<Span, PropertyLvarPortDirection> {
274 let (s, a) = keyword("input")(s)?;
275 Ok((s, PropertyLvarPortDirection::Input(Box::new(a))))
276}
277
278#[tracable_parser]
279#[packrat_parser]
280pub(crate) fn property_formal_type(s: Span) -> IResult<Span, PropertyFormalType> {
281 alt((
282 map(sequence_formal_type, |x| {
283 PropertyFormalType::SequenceFormalType(Box::new(x))
284 }),
285 map(keyword("property"), |x| {
286 PropertyFormalType::Property(Box::new(x))
287 }),
288 ))(s)
289}
290
291#[recursive_parser]
292#[tracable_parser]
293#[packrat_parser]
294pub(crate) fn property_spec(s: Span) -> IResult<Span, PropertySpec> {
295 let (s, a) = opt(clocking_event)(s)?;
296 let (s, b) = opt(triple(
297 keyword("disable"),
298 keyword("iff"),
299 paren(expression_or_dist),
300 ))(s)?;
301 let (s, c) = property_expr(s)?;
302 Ok((s, PropertySpec { nodes: (a, b, c) }))
303}
304
305#[tracable_parser]
306#[packrat_parser]
307pub(crate) fn property_expr(s: Span) -> IResult<Span, PropertyExpr> {
308 alt((
309 alt((
310 property_expr_binary_property,
311 property_expr_binary_sequence,
312 map(terminated(sequence_expr, peek(not(symbol("(")))), |x| {
313 PropertyExpr::SequenceExpr(Box::new(x))
314 }),
315 property_expr_strong,
316 property_expr_weak,
317 property_expr_not,
318 property_expr_paren,
319 )),
320 alt((
321 property_expr_if,
322 property_expr_case,
323 property_expr_nexttime,
324 property_expr_s_nexttime,
325 property_expr_always,
326 property_expr_s_always,
327 property_expr_eventually,
328 property_expr_s_eventually,
329 property_expr_accept_on,
330 property_expr_reject_on,
331 property_expr_sync_accept_on,
332 property_expr_sync_reject_on,
333 map(property_instance, |x| {
334 PropertyExpr::PropertyInstance(Box::new(x))
335 }),
336 property_expr_clocking_event,
337 )),
338 ))(s)
339}
340
341#[tracable_parser]
342#[packrat_parser]
343pub(crate) fn property_expr_strong(s: Span) -> IResult<Span, PropertyExpr> {
344 let (s, a) = keyword("strong")(s)?;
345 let (s, b) = paren(sequence_expr)(s)?;
346 Ok((
347 s,
348 PropertyExpr::Strong(Box::new(PropertyExprStrong { nodes: (a, b) })),
349 ))
350}
351
352#[tracable_parser]
353#[packrat_parser]
354pub(crate) fn property_expr_weak(s: Span) -> IResult<Span, PropertyExpr> {
355 let (s, a) = keyword("weak")(s)?;
356 let (s, b) = paren(sequence_expr)(s)?;
357 Ok((
358 s,
359 PropertyExpr::Strong(Box::new(PropertyExprStrong { nodes: (a, b) })),
360 ))
361}
362
363#[tracable_parser]
364#[packrat_parser]
365pub(crate) fn property_expr_paren(s: Span) -> IResult<Span, PropertyExpr> {
366 let (s, a) = paren(property_expr)(s)?;
367 Ok((
368 s,
369 PropertyExpr::Paren(Box::new(PropertyExprParen { nodes: (a,) })),
370 ))
371}
372
373#[tracable_parser]
374#[packrat_parser]
375pub(crate) fn property_expr_not(s: Span) -> IResult<Span, PropertyExpr> {
376 let (s, a) = keyword("not")(s)?;
377 let (s, b) = property_expr(s)?;
378 Ok((
379 s,
380 PropertyExpr::Not(Box::new(PropertyExprNot { nodes: (a, b) })),
381 ))
382}
383
384#[recursive_parser]
385#[tracable_parser]
386#[packrat_parser]
387pub(crate) fn property_expr_binary_property(s: Span) -> IResult<Span, PropertyExpr> {
388 let (s, a) = property_expr(s)?;
389 let (s, b) = alt((
390 keyword("or"),
391 keyword("and"),
392 keyword("until_with"),
393 keyword("until"),
394 keyword("s_until_with"),
395 keyword("s_until"),
396 keyword("implies"),
397 keyword("iff"),
398 ))(s)?;
399 let (s, c) = property_expr(s)?;
400 Ok((
401 s,
402 PropertyExpr::BinaryProperty(Box::new(PropertyExprBinaryProperty { nodes: (a, b, c) })),
403 ))
404}
405
406#[recursive_parser]
407#[tracable_parser]
408#[packrat_parser]
409pub(crate) fn property_expr_binary_sequence(s: Span) -> IResult<Span, PropertyExpr> {
410 let (s, a) = sequence_expr(s)?;
411 let (s, b) = alt((symbol("|->"), symbol("|=>"), symbol("#-#"), symbol("#=#")))(s)?;
412 let (s, c) = property_expr(s)?;
413 Ok((
414 s,
415 PropertyExpr::BinarySequence(Box::new(PropertyExprBinarySequence { nodes: (a, b, c) })),
416 ))
417}
418
419#[tracable_parser]
420#[packrat_parser]
421pub(crate) fn property_expr_if(s: Span) -> IResult<Span, PropertyExpr> {
422 let (s, a) = keyword("if")(s)?;
423 let (s, b) = paren(expression_or_dist)(s)?;
424 let (s, c) = property_expr(s)?;
425 let (s, d) = opt(pair(keyword("else"), property_expr))(s)?;
426 Ok((
427 s,
428 PropertyExpr::If(Box::new(PropertyExprIf {
429 nodes: (a, b, c, d),
430 })),
431 ))
432}
433
434#[tracable_parser]
435#[packrat_parser]
436pub(crate) fn property_expr_case(s: Span) -> IResult<Span, PropertyExpr> {
437 let (s, a) = keyword("case")(s)?;
438 let (s, b) = paren(expression_or_dist)(s)?;
439 let (s, c) = property_case_item(s)?;
440 let (s, (d, e)) = many_till(property_case_item, keyword("endcase"))(s)?;
441 Ok((
442 s,
443 PropertyExpr::Case(Box::new(PropertyExprCase {
444 nodes: (a, b, c, d, e),
445 })),
446 ))
447}
448#[tracable_parser]
449#[packrat_parser]
450pub(crate) fn property_expr_nexttime(s: Span) -> IResult<Span, PropertyExpr> {
451 let (s, a) = keyword("nexttime")(s)?;
452 let (s, b) = opt(bracket(constant_expression))(s)?;
453 let (s, c) = property_expr(s)?;
454 Ok((
455 s,
456 PropertyExpr::Nexttime(Box::new(PropertyExprNexttime { nodes: (a, b, c) })),
457 ))
458}
459
460#[tracable_parser]
461#[packrat_parser]
462pub(crate) fn property_expr_s_nexttime(s: Span) -> IResult<Span, PropertyExpr> {
463 let (s, a) = keyword("s_nexttime")(s)?;
464 let (s, b) = opt(bracket(constant_expression))(s)?;
465 let (s, c) = property_expr(s)?;
466 Ok((
467 s,
468 PropertyExpr::SNexttime(Box::new(PropertyExprSNexttime { nodes: (a, b, c) })),
469 ))
470}
471
472#[tracable_parser]
473#[packrat_parser]
474pub(crate) fn property_expr_always(s: Span) -> IResult<Span, PropertyExpr> {
475 let (s, a) = keyword("always")(s)?;
476 let (s, b) = opt(bracket(cycle_delay_const_range_expression))(s)?;
477 let (s, c) = property_expr(s)?;
478 Ok((
479 s,
480 PropertyExpr::Always(Box::new(PropertyExprAlways { nodes: (a, b, c) })),
481 ))
482}
483
484#[tracable_parser]
485#[packrat_parser]
486pub(crate) fn property_expr_s_always(s: Span) -> IResult<Span, PropertyExpr> {
487 let (s, a) = keyword("s_always")(s)?;
488 let (s, b) = bracket(cycle_delay_const_range_expression)(s)?;
489 let (s, c) = property_expr(s)?;
490 Ok((
491 s,
492 PropertyExpr::SAlways(Box::new(PropertyExprSAlways { nodes: (a, b, c) })),
493 ))
494}
495
496#[tracable_parser]
497#[packrat_parser]
498pub(crate) fn property_expr_eventually(s: Span) -> IResult<Span, PropertyExpr> {
499 let (s, a) = keyword("eventually")(s)?;
500 let (s, b) = bracket(constant_range)(s)?;
501 let (s, c) = property_expr(s)?;
502 Ok((
503 s,
504 PropertyExpr::Eventually(Box::new(PropertyExprEventually { nodes: (a, b, c) })),
505 ))
506}
507
508#[tracable_parser]
509#[packrat_parser]
510pub(crate) fn property_expr_s_eventually(s: Span) -> IResult<Span, PropertyExpr> {
511 let (s, a) = keyword("s_eventually")(s)?;
512 let (s, b) = opt(bracket(cycle_delay_const_range_expression))(s)?;
513 let (s, c) = property_expr(s)?;
514 Ok((
515 s,
516 PropertyExpr::SEventually(Box::new(PropertyExprSEventually { nodes: (a, b, c) })),
517 ))
518}
519
520#[tracable_parser]
521#[packrat_parser]
522pub(crate) fn property_expr_accept_on(s: Span) -> IResult<Span, PropertyExpr> {
523 let (s, a) = keyword("accept_on")(s)?;
524 let (s, b) = paren(expression_or_dist)(s)?;
525 let (s, c) = property_expr(s)?;
526 Ok((
527 s,
528 PropertyExpr::AcceptOn(Box::new(PropertyExprAcceptOn { nodes: (a, b, c) })),
529 ))
530}
531
532#[tracable_parser]
533#[packrat_parser]
534pub(crate) fn property_expr_reject_on(s: Span) -> IResult<Span, PropertyExpr> {
535 let (s, a) = keyword("reject_on")(s)?;
536 let (s, b) = paren(expression_or_dist)(s)?;
537 let (s, c) = property_expr(s)?;
538 Ok((
539 s,
540 PropertyExpr::RejectOn(Box::new(PropertyExprRejectOn { nodes: (a, b, c) })),
541 ))
542}
543
544#[tracable_parser]
545#[packrat_parser]
546pub(crate) fn property_expr_sync_accept_on(s: Span) -> IResult<Span, PropertyExpr> {
547 let (s, a) = keyword("sync_accept_on")(s)?;
548 let (s, b) = paren(expression_or_dist)(s)?;
549 let (s, c) = property_expr(s)?;
550 Ok((
551 s,
552 PropertyExpr::SyncAcceptOn(Box::new(PropertyExprSyncAcceptOn { nodes: (a, b, c) })),
553 ))
554}
555
556#[tracable_parser]
557#[packrat_parser]
558pub(crate) fn property_expr_sync_reject_on(s: Span) -> IResult<Span, PropertyExpr> {
559 let (s, a) = keyword("sync_reject_on")(s)?;
560 let (s, b) = paren(expression_or_dist)(s)?;
561 let (s, c) = property_expr(s)?;
562 Ok((
563 s,
564 PropertyExpr::SyncRejectOn(Box::new(PropertyExprSyncRejectOn { nodes: (a, b, c) })),
565 ))
566}
567
568#[tracable_parser]
569#[packrat_parser]
570pub(crate) fn property_expr_clocking_event(s: Span) -> IResult<Span, PropertyExpr> {
571 let (s, a) = clocking_event(s)?;
572 let (s, b) = property_expr(s)?;
573 Ok((
574 s,
575 PropertyExpr::ClockingEvent(Box::new(PropertyExprClockingEvent { nodes: (a, b) })),
576 ))
577}
578
579#[tracable_parser]
580#[packrat_parser]
581pub(crate) fn property_case_item(s: Span) -> IResult<Span, PropertyCaseItem> {
582 alt((property_case_item_nondefault, property_case_item_default))(s)
583}
584
585#[recursive_parser]
586#[tracable_parser]
587#[packrat_parser]
588pub(crate) fn property_case_item_nondefault(s: Span) -> IResult<Span, PropertyCaseItem> {
589 let (s, a) = list(symbol(","), expression_or_dist)(s)?;
590 let (s, b) = symbol(":")(s)?;
591 let (s, c) = property_expr(s)?;
592 let (s, d) = symbol(";")(s)?;
593 Ok((
594 s,
595 PropertyCaseItem::Nondefault(Box::new(PropertyCaseItemNondefault {
596 nodes: (a, b, c, d),
597 })),
598 ))
599}
600
601#[tracable_parser]
602#[packrat_parser]
603pub(crate) fn property_case_item_default(s: Span) -> IResult<Span, PropertyCaseItem> {
604 let (s, a) = keyword("default")(s)?;
605 let (s, b) = opt(symbol(":"))(s)?;
606 let (s, c) = property_expr(s)?;
607 let (s, d) = symbol(";")(s)?;
608 Ok((
609 s,
610 PropertyCaseItem::Default(Box::new(PropertyCaseItemDefault {
611 nodes: (a, b, c, d),
612 })),
613 ))
614}
615
616#[tracable_parser]
617#[packrat_parser]
618pub(crate) fn sequence_declaration(s: Span) -> IResult<Span, SequenceDeclaration> {
619 let (s, a) = keyword("sequence")(s)?;
620 let (s, b) = sequence_identifier(s)?;
621 let (s, c) = opt(paren(opt(sequence_port_list)))(s)?;
622 let (s, d) = symbol(";")(s)?;
623 let (s, e) = many0(assertion_variable_declaration)(s)?;
624 let (s, f) = sequence_expr(s)?;
625 let (s, g) = opt(symbol(";"))(s)?;
626 let (s, h) = keyword("endsequence")(s)?;
627 let (s, i) = opt(pair(symbol(":"), sequence_identifier))(s)?;
628 Ok((
629 s,
630 SequenceDeclaration {
631 nodes: (a, b, c, d, e, f, g, h, i),
632 },
633 ))
634}
635
636#[tracable_parser]
637#[packrat_parser]
638pub(crate) fn sequence_port_list(s: Span) -> IResult<Span, SequencePortList> {
639 let (s, a) = list(symbol(","), sequence_port_item)(s)?;
640 Ok((s, SequencePortList { nodes: (a,) }))
641}
642
643#[tracable_parser]
644#[packrat_parser]
645pub(crate) fn sequence_port_item(s: Span) -> IResult<Span, SequencePortItem> {
646 let (s, a) = many0(attribute_instance)(s)?;
647 let (s, b) = opt(pair(keyword("local"), opt(sequence_lvar_port_direction)))(s)?;
648 let (s, c) = sequence_formal_type(s)?;
649 let (s, d) = formal_port_identifier(s)?;
650 let (s, e) = many0(variable_dimension)(s)?;
651 let (s, f) = opt(pair(symbol("="), sequence_actual_arg))(s)?;
652 Ok((
653 s,
654 SequencePortItem {
655 nodes: (a, b, c, d, e, f),
656 },
657 ))
658}
659
660#[tracable_parser]
661#[packrat_parser]
662pub(crate) fn sequence_lvar_port_direction(s: Span) -> IResult<Span, SequenceLvarPortDirection> {
663 alt((
664 map(keyword("input"), |x| {
665 SequenceLvarPortDirection::Input(Box::new(x))
666 }),
667 map(keyword("inout"), |x| {
668 SequenceLvarPortDirection::Inout(Box::new(x))
669 }),
670 map(keyword("output"), |x| {
671 SequenceLvarPortDirection::Output(Box::new(x))
672 }),
673 ))(s)
674}
675
676#[tracable_parser]
677#[packrat_parser]
678pub(crate) fn sequence_formal_type(s: Span) -> IResult<Span, SequenceFormalType> {
679 alt((
680 map(data_type_or_implicit_sequence_formal_type, |x| {
681 SequenceFormalType::DataTypeOrImplicit(Box::new(x))
682 }),
683 map(keyword("sequence"), |x| {
684 SequenceFormalType::Sequence(Box::new(x))
685 }),
686 map(keyword("untyped"), |x| {
687 SequenceFormalType::Untyped(Box::new(x))
688 }),
689 ))(s)
690}
691
692#[tracable_parser]
693#[packrat_parser]
694pub(crate) fn data_type_or_implicit_sequence_formal_type(
695 s: Span,
696) -> IResult<Span, DataTypeOrImplicit> {
697 alt((
698 map(terminated(data_type, peek(formal_port_identifier)), |x| {
699 DataTypeOrImplicit::DataType(Box::new(x))
700 }),
701 map(
702 terminated(implicit_data_type, peek(formal_port_identifier)),
703 |x| DataTypeOrImplicit::ImplicitDataType(Box::new(x)),
704 ),
705 ))(s)
706}
707
708#[tracable_parser]
709#[packrat_parser]
710pub(crate) fn sequence_expr(s: Span) -> IResult<Span, SequenceExpr> {
711 alt((
712 sequence_expr_binary,
713 sequence_expr_expr_cycle_delay_expr,
714 sequence_expr_cycle_delay_expr,
715 sequence_expr_throughout,
716 terminated(sequence_expr_expression, peek(not(symbol("(")))),
717 sequence_expr_instance,
718 sequence_expr_paren,
719 sequence_expr_first_match,
720 sequence_expr_clocking_event,
721 ))(s)
722}
723
724#[tracable_parser]
725#[packrat_parser]
726pub(crate) fn sequence_expr_cycle_delay_expr(s: Span) -> IResult<Span, SequenceExpr> {
727 let (s, (a, b)) = alt((
728 pair(cycle_delay_range, sequence_expr),
729 pair(cycle_delay_range_2, sequence_expr),
730 ))(s)?;
731 let (s, c) = many0(pair(cycle_delay_range, sequence_expr))(s)?;
732 Ok((
733 s,
734 SequenceExpr::CycleDelayExpr(Box::new(SequenceExprCycleDelayExpr { nodes: (a, b, c) })),
735 ))
736}
737
738#[recursive_parser]
739#[tracable_parser]
740#[packrat_parser]
741pub(crate) fn sequence_expr_expr_cycle_delay_expr(s: Span) -> IResult<Span, SequenceExpr> {
742 let (s, a) = sequence_expr(s)?;
743 let (s, (b, c)) = alt((
744 pair(cycle_delay_range, sequence_expr),
745 pair(cycle_delay_range_2, sequence_expr),
746 ))(s)?;
747 let (s, d) = many0(pair(cycle_delay_range, sequence_expr))(s)?;
748 Ok((
749 s,
750 SequenceExpr::ExprCycleDelayExpr(Box::new(SequenceExprExprCycleDelayExpr {
751 nodes: (a, b, c, d),
752 })),
753 ))
754}
755
756#[recursive_parser]
757#[tracable_parser]
758#[packrat_parser]
759pub(crate) fn sequence_expr_expression(s: Span) -> IResult<Span, SequenceExpr> {
760 let (s, a) = expression_or_dist(s)?;
761 let (s, b) = opt(boolean_abbrev)(s)?;
762 Ok((
763 s,
764 SequenceExpr::Expression(Box::new(SequenceExprExpression { nodes: (a, b) })),
765 ))
766}
767
768#[tracable_parser]
769#[packrat_parser]
770pub(crate) fn sequence_expr_instance(s: Span) -> IResult<Span, SequenceExpr> {
771 let (s, a) = sequence_instance(s)?;
772 let (s, b) = opt(sequence_abbrev)(s)?;
773 Ok((
774 s,
775 SequenceExpr::Instance(Box::new(SequenceExprInstance { nodes: (a, b) })),
776 ))
777}
778
779#[tracable_parser]
780#[packrat_parser]
781pub(crate) fn sequence_expr_paren(s: Span) -> IResult<Span, SequenceExpr> {
782 let (s, a) = paren(pair(
783 sequence_expr,
784 many0(pair(symbol(","), sequence_match_item)),
785 ))(s)?;
786 let (s, b) = opt(sequence_abbrev)(s)?;
787 Ok((
788 s,
789 SequenceExpr::Paren(Box::new(SequenceExprParen { nodes: (a, b) })),
790 ))
791}
792
793#[recursive_parser]
794#[tracable_parser]
795#[packrat_parser]
796pub(crate) fn sequence_expr_binary(s: Span) -> IResult<Span, SequenceExpr> {
797 let (s, a) = sequence_expr(s)?;
798 let (s, b) = alt((
799 keyword("and"),
800 keyword("intersect"),
801 keyword("or"),
802 keyword("within"),
803 ))(s)?;
804 let (s, c) = sequence_expr(s)?;
805 Ok((
806 s,
807 SequenceExpr::Binary(Box::new(SequenceExprBinary { nodes: (a, b, c) })),
808 ))
809}
810
811#[tracable_parser]
812#[packrat_parser]
813pub(crate) fn sequence_expr_first_match(s: Span) -> IResult<Span, SequenceExpr> {
814 let (s, a) = keyword("first_match")(s)?;
815 let (s, b) = paren(pair(
816 sequence_expr,
817 many0(pair(symbol(","), sequence_match_item)),
818 ))(s)?;
819 Ok((
820 s,
821 SequenceExpr::FirstMatch(Box::new(SequenceExprFirstMatch { nodes: (a, b) })),
822 ))
823}
824
825#[recursive_parser]
826#[tracable_parser]
827#[packrat_parser]
828pub(crate) fn sequence_expr_throughout(s: Span) -> IResult<Span, SequenceExpr> {
829 let (s, a) = expression_or_dist(s)?;
830 let (s, b) = keyword("throughout")(s)?;
831 let (s, c) = sequence_expr(s)?;
832 Ok((
833 s,
834 SequenceExpr::Throughout(Box::new(SequenceExprThroughout { nodes: (a, b, c) })),
835 ))
836}
837
838#[tracable_parser]
839#[packrat_parser]
840pub(crate) fn sequence_expr_clocking_event(s: Span) -> IResult<Span, SequenceExpr> {
841 let (s, a) = clocking_event(s)?;
842 let (s, b) = sequence_expr(s)?;
843 Ok((
844 s,
845 SequenceExpr::ClockingEvent(Box::new(SequenceExprClockingEvent { nodes: (a, b) })),
846 ))
847}
848
849#[tracable_parser]
850#[packrat_parser]
851pub(crate) fn cycle_delay_range(s: Span) -> IResult<Span, CycleDelayRange> {
852 alt((
853 cycle_delay_range_primary,
854 cycle_delay_range_expression,
855 cycle_delay_range_asterisk,
856 cycle_delay_range_plus,
857 ))(s)
858}
859
860#[tracable_parser]
861#[packrat_parser]
862pub(crate) fn cycle_delay_range_2(s: Span) -> IResult<Span, CycleDelayRange> {
863 alt((
864 cycle_delay_range_primary_no_function,
865 cycle_delay_range_expression,
866 cycle_delay_range_asterisk,
867 cycle_delay_range_plus,
868 ))(s)
869}
870
871#[tracable_parser]
872#[packrat_parser]
873pub(crate) fn cycle_delay_range_primary(s: Span) -> IResult<Span, CycleDelayRange> {
874 let (s, a) = symbol("##")(s)?;
875 let (s, b) = constant_primary(s)?;
876 Ok((
877 s,
878 CycleDelayRange::Primary(Box::new(CycleDelayRangePrimary { nodes: (a, b) })),
879 ))
880}
881
882#[tracable_parser]
883#[packrat_parser]
884pub(crate) fn cycle_delay_range_primary_no_function(s: Span) -> IResult<Span, CycleDelayRange> {
885 let (s, a) = symbol("##")(s)?;
886 let (s, b) = constant_primary_no_function(s)?;
887 Ok((
888 s,
889 CycleDelayRange::Primary(Box::new(CycleDelayRangePrimary { nodes: (a, b) })),
890 ))
891}
892
893#[tracable_parser]
894#[packrat_parser]
895pub(crate) fn cycle_delay_range_expression(s: Span) -> IResult<Span, CycleDelayRange> {
896 let (s, a) = symbol("##")(s)?;
897 let (s, b) = bracket(cycle_delay_const_range_expression)(s)?;
898 Ok((
899 s,
900 CycleDelayRange::Expression(Box::new(CycleDelayRangeExpression { nodes: (a, b) })),
901 ))
902}
903
904#[tracable_parser]
905#[packrat_parser]
906pub(crate) fn cycle_delay_range_asterisk(s: Span) -> IResult<Span, CycleDelayRange> {
907 let (s, a) = symbol("##")(s)?;
908 let (s, b) = bracket(symbol("*"))(s)?;
909 Ok((
910 s,
911 CycleDelayRange::Asterisk(Box::new(CycleDelayRangeAsterisk { nodes: (a, b) })),
912 ))
913}
914
915#[tracable_parser]
916#[packrat_parser]
917pub(crate) fn cycle_delay_range_plus(s: Span) -> IResult<Span, CycleDelayRange> {
918 let (s, a) = symbol("##")(s)?;
919 let (s, b) = bracket(symbol("+"))(s)?;
920 Ok((
921 s,
922 CycleDelayRange::Plus(Box::new(CycleDelayRangePlus { nodes: (a, b) })),
923 ))
924}
925
926#[tracable_parser]
927#[packrat_parser]
928pub(crate) fn sequence_method_call(s: Span) -> IResult<Span, SequenceMethodCall> {
929 let (s, a) = sequence_instance(s)?;
930 let (s, b) = symbol(".")(s)?;
931 let (s, c) = method_identifier(s)?;
932 Ok((s, SequenceMethodCall { nodes: (a, b, c) }))
933}
934
935#[tracable_parser]
936#[packrat_parser]
937pub(crate) fn sequence_match_item(s: Span) -> IResult<Span, SequenceMatchItem> {
938 alt((
939 map(operator_assignment, |x| {
940 SequenceMatchItem::OperatorAssignment(Box::new(x))
941 }),
942 map(inc_or_dec_expression, |x| {
943 SequenceMatchItem::IncOrDecExpression(Box::new(x))
944 }),
945 map(subroutine_call, |x| {
946 SequenceMatchItem::SubroutineCall(Box::new(x))
947 }),
948 ))(s)
949}
950
951#[tracable_parser]
952#[packrat_parser]
953pub(crate) fn sequence_instance(s: Span) -> IResult<Span, SequenceInstance> {
954 let (s, a) = ps_or_hierarchical_sequence_identifier(s)?;
955 let (s, b) = opt(paren(opt(sequence_list_of_arguments)))(s)?;
956 Ok((s, SequenceInstance { nodes: (a, b) }))
957}
958
959#[tracable_parser]
960#[packrat_parser]
961pub(crate) fn sequence_list_of_arguments(s: Span) -> IResult<Span, SequenceListOfArguments> {
962 alt((
963 sequence_list_of_arguments_named,
964 sequence_list_of_arguments_ordered,
965 ))(s)
966}
967
968#[recursive_parser]
969#[tracable_parser]
970#[packrat_parser]
971pub(crate) fn sequence_list_of_arguments_ordered(
972 s: Span,
973) -> IResult<Span, SequenceListOfArguments> {
974 let (s, a) = list(symbol(","), opt(sequence_actual_arg))(s)?;
975 let (s, b) = many0(tuple((
976 symbol(","),
977 symbol("."),
978 identifier,
979 paren(opt(sequence_actual_arg)),
980 )))(s)?;
981 Ok((
982 s,
983 SequenceListOfArguments::Ordered(Box::new(SequenceListOfArgumentsOrdered {
984 nodes: (a, b),
985 })),
986 ))
987}
988
989#[tracable_parser]
990#[packrat_parser]
991pub(crate) fn sequence_list_of_arguments_named(s: Span) -> IResult<Span, SequenceListOfArguments> {
992 let (s, a) = list(
993 symbol(","),
994 triple(symbol("."), identifier, paren(opt(sequence_actual_arg))),
995 )(s)?;
996 Ok((
997 s,
998 SequenceListOfArguments::Named(Box::new(SequenceListOfArgumentsNamed { nodes: (a,) })),
999 ))
1000}
1001
1002#[tracable_parser]
1003#[packrat_parser]
1004pub(crate) fn sequence_actual_arg(s: Span) -> IResult<Span, SequenceActualArg> {
1005 alt((
1006 map(sequence_expr, |x| {
1007 SequenceActualArg::SequenceExpr(Box::new(x))
1008 }),
1009 map(event_expression_sequence_actual_arg, |x| {
1010 SequenceActualArg::EventExpression(Box::new(x))
1011 }),
1012 ))(s)
1013}
1014
1015#[tracable_parser]
1016#[packrat_parser]
1017pub(crate) fn event_expression_sequence_actual_arg(s: Span) -> IResult<Span, EventExpression> {
1018 alt((
1019 event_expression_or_sequence_actual_arg,
1020 event_expression_expression,
1021 event_expression_sequence,
1022 event_expression_paren,
1023 ))(s)
1024}
1025
1026#[recursive_parser]
1027#[tracable_parser]
1028#[packrat_parser]
1029pub(crate) fn event_expression_or_sequence_actual_arg(s: Span) -> IResult<Span, EventExpression> {
1030 let (s, a) = event_expression_sequence_actual_arg(s)?;
1031 let (s, b) = keyword("or")(s)?;
1032 let (s, c) = event_expression_sequence_actual_arg(s)?;
1033 Ok((
1034 s,
1035 EventExpression::Or(Box::new(EventExpressionOr { nodes: (a, b, c) })),
1036 ))
1037}
1038
1039#[tracable_parser]
1040#[packrat_parser]
1041pub(crate) fn boolean_abbrev(s: Span) -> IResult<Span, BooleanAbbrev> {
1042 alt((
1043 map(consecutive_repetition, |x| {
1044 BooleanAbbrev::ConsecutiveRepetition(Box::new(x))
1045 }),
1046 map(non_consecutive_repetition, |x| {
1047 BooleanAbbrev::NonConsecutiveRepetition(Box::new(x))
1048 }),
1049 map(goto_repetition, |x| {
1050 BooleanAbbrev::GotoRepetition(Box::new(x))
1051 }),
1052 ))(s)
1053}
1054
1055#[tracable_parser]
1056#[packrat_parser]
1057pub(crate) fn sequence_abbrev(s: Span) -> IResult<Span, SequenceAbbrev> {
1058 let (s, a) = consecutive_repetition(s)?;
1059 Ok((s, SequenceAbbrev { nodes: (a,) }))
1060}
1061
1062#[tracable_parser]
1063#[packrat_parser]
1064pub(crate) fn consecutive_repetition(s: Span) -> IResult<Span, ConsecutiveRepetition> {
1065 alt((
1066 consecutive_repetition_expression,
1067 consecutive_repetition_asterisk,
1068 consecutive_repetition_plus,
1069 ))(s)
1070}
1071
1072#[tracable_parser]
1073#[packrat_parser]
1074pub(crate) fn consecutive_repetition_expression(s: Span) -> IResult<Span, ConsecutiveRepetition> {
1075 let (s, a) = bracket(pair(symbol("*"), const_or_range_expression))(s)?;
1076 Ok((
1077 s,
1078 ConsecutiveRepetition::Expression(Box::new(ConsecutiveRepetitionExpression {
1079 nodes: (a,),
1080 })),
1081 ))
1082}
1083
1084#[tracable_parser]
1085#[packrat_parser]
1086pub(crate) fn consecutive_repetition_asterisk(s: Span) -> IResult<Span, ConsecutiveRepetition> {
1087 let (s, a) = bracket(symbol("*"))(s)?;
1088 Ok((
1089 s,
1090 ConsecutiveRepetition::Asterisk(Box::new(ConsecutiveRepetitionAsterisk { nodes: (a,) })),
1091 ))
1092}
1093
1094#[tracable_parser]
1095#[packrat_parser]
1096pub(crate) fn consecutive_repetition_plus(s: Span) -> IResult<Span, ConsecutiveRepetition> {
1097 let (s, a) = bracket(symbol("+"))(s)?;
1098 Ok((
1099 s,
1100 ConsecutiveRepetition::Plus(Box::new(ConsecutiveRepetitionPlus { nodes: (a,) })),
1101 ))
1102}
1103
1104#[tracable_parser]
1105#[packrat_parser]
1106pub(crate) fn non_consecutive_repetition(s: Span) -> IResult<Span, NonConsecutiveRepetition> {
1107 let (s, a) = bracket(pair(symbol("="), const_or_range_expression))(s)?;
1108 Ok((s, NonConsecutiveRepetition { nodes: (a,) }))
1109}
1110
1111#[tracable_parser]
1112#[packrat_parser]
1113pub(crate) fn goto_repetition(s: Span) -> IResult<Span, GotoRepetition> {
1114 let (s, a) = bracket(pair(symbol("->"), const_or_range_expression))(s)?;
1115 Ok((s, GotoRepetition { nodes: (a,) }))
1116}
1117
1118#[tracable_parser]
1119#[packrat_parser]
1120pub(crate) fn const_or_range_expression(s: Span) -> IResult<Span, ConstOrRangeExpression> {
1121 alt((
1122 map(cycle_delay_const_range_expression, |x| {
1123 ConstOrRangeExpression::CycleDelayConstRangeExpression(Box::new(x))
1124 }),
1125 map(constant_expression, |x| {
1126 ConstOrRangeExpression::ConstantExpression(Box::new(x))
1127 }),
1128 ))(s)
1129}
1130
1131#[tracable_parser]
1132#[packrat_parser]
1133pub(crate) fn cycle_delay_const_range_expression(
1134 s: Span,
1135) -> IResult<Span, CycleDelayConstRangeExpression> {
1136 alt((
1137 cycle_delay_const_range_expression_binary,
1138 cycle_delay_const_range_expression_dollar,
1139 ))(s)
1140}
1141
1142#[recursive_parser]
1143#[tracable_parser]
1144#[packrat_parser]
1145pub(crate) fn cycle_delay_const_range_expression_binary(
1146 s: Span,
1147) -> IResult<Span, CycleDelayConstRangeExpression> {
1148 let (s, a) = constant_expression(s)?;
1149 let (s, b) = symbol(":")(s)?;
1150 let (s, c) = constant_expression(s)?;
1151 Ok((
1152 s,
1153 CycleDelayConstRangeExpression::Binary(Box::new(CycleDelayConstRangeExpressionBinary {
1154 nodes: (a, b, c),
1155 })),
1156 ))
1157}
1158
1159#[recursive_parser]
1160#[tracable_parser]
1161#[packrat_parser]
1162pub(crate) fn cycle_delay_const_range_expression_dollar(
1163 s: Span,
1164) -> IResult<Span, CycleDelayConstRangeExpression> {
1165 let (s, a) = constant_expression(s)?;
1166 let (s, b) = symbol(":")(s)?;
1167 let (s, c) = symbol("$")(s)?;
1168 Ok((
1169 s,
1170 CycleDelayConstRangeExpression::Dollar(Box::new(CycleDelayConstRangeExpressionDollar {
1171 nodes: (a, b, c),
1172 })),
1173 ))
1174}
1175
1176#[recursive_parser]
1177#[tracable_parser]
1178#[packrat_parser]
1179pub(crate) fn expression_or_dist(s: Span) -> IResult<Span, ExpressionOrDist> {
1180 let (s, a) = expression(s)?;
1181 let (s, b) = opt(pair(keyword("dist"), brace(dist_list)))(s)?;
1182 Ok((s, ExpressionOrDist { nodes: (a, b) }))
1183}
1184
1185#[tracable_parser]
1186#[packrat_parser]
1187pub(crate) fn assertion_variable_declaration(
1188 s: Span,
1189) -> IResult<Span, AssertionVariableDeclaration> {
1190 let (s, a) = var_data_type(s)?;
1191 let (s, b) = list_of_variable_decl_assignments(s)?;
1192 let (s, c) = symbol(";")(s)?;
1193 Ok((s, AssertionVariableDeclaration { nodes: (a, b, c) }))
1194}