43 lines · javascript
1'use strict';2 3module.exports = {4 cf_dialect : $ => prec.right(choice(5 // operation ::= `cf.assert` $arg `,` $msg attr-dict6 seq('cf.assert', field('argument', $.value_use), ',',7 field('message', $.string_literal),8 field('attributes', optional($.attribute))),9 10 // operation ::= `cf.br` $dest (`(` $destOperands^ `:`11 // type($destOperands) `)`)? attr-dict12 seq('cf.br', field('successor', $.successor),13 field('attributes', optional($.attribute))),14 15 // operation ::= `cf.cond_br` $condition `,`16 // $trueDest(`(` $trueDestOperands ^ `:`17 // type($trueDestOperands)`)`)? `,`18 // $falseDest(`(` $falseDestOperands ^ `:`19 // type($falseDestOperands)`)`)? attr-dict20 seq('cf.cond_br', field('condition', $.value_use), ',',21 field('trueblk', $.successor), ',',22 field('falseblk', $.successor),23 field('attributes', optional($.attribute))),24 25 // operation ::= `cf.switch` $flag `:` type($flag) `,` `[` `\n`26 // custom<SwitchOpCases>(ref(type($flag)),$defaultDestination,27 // $defaultOperands,28 // type($defaultOperands),29 // $case_values,30 // $caseDestinations,31 // $caseOperands,32 // type($caseOperands))33 // `]`34 // attr-dict35 seq('cf.switch', field('flag', $._value_use_and_type), ',',36 '[', $.cf_case_label, $.successor,37 repeat(seq(',', $.cf_case_label, $.successor)), ']',38 field('attributes', optional($.attribute))),39 )),40 41 cf_case_label : $ => seq(choice($.integer_literal, token('default')), ':')42}43