130 lines · javascript
1'use strict';2 3module.exports = {4 math_dialect : $ => choice(5 // operation ::= `math.absf` $operand (`fastmath` ``6 // $fastmath^)?7 // attr-dict `:` type($result)8 // operation ::= `math.atan` $operand (`fastmath` ``9 // $fastmath^)?10 // attr-dict `:` type($result)11 // operation ::= `math.cbrt` $operand (`fastmath` ``12 // $fastmath^)?13 // attr-dict `:` type($result)14 // operation ::= `math.ceil` $operand (`fastmath` ``15 // $fastmath^)?16 // attr-dict `:` type($result)17 // operation ::= `math.cos` $operand (`fastmath` ``18 // $fastmath^)?19 // attr-dict `:` type($result)20 // operation ::= `math.erf` $operand (`fastmath` ``21 // $fastmath^)?22 // attr-dict `:` type($result)23 // operation ::= `math.exp` $operand (`fastmath` ``24 // $fastmath^)?25 // attr-dict `:` type($result)26 // operation ::= `math.exp2` $operand (`fastmath` ``27 // $fastmath^)?28 // attr-dict `:` type($result)29 // operation ::= `math.expm1` $operand (`fastmath` ``30 // $fastmath^)?31 // attr-dict `:` type($result)32 // operation ::= `math.floor` $operand (`fastmath` ``33 // $fastmath^)?34 // attr-dict `:` type($result)35 // operation ::= `math.log` $operand (`fastmath` ``36 // $fastmath^)?37 // attr-dict `:` type($result)38 // operation ::= `math.log10` $operand (`fastmath` ``39 // $fastmath^)?40 // attr-dict `:` type($result)41 // operation ::= `math.log1p` $operand (`fastmath` ``42 // $fastmath^)?43 // attr-dict `:` type($result)44 // operation ::= `math.log2` $operand (`fastmath` ``45 // $fastmath^)?46 // attr-dict `:` type($result)47 // operation ::= `math.round` $operand (`fastmath` ``48 // $fastmath^)?49 // attr-dict `:` type($result)50 // operation ::= `math.roundeven` $operand (`fastmath` ``51 // $fastmath^)?52 // attr-dict `:` type($result)53 // operation ::= `math.rsqrt` $operand (`fastmath` ``54 // $fastmath^)?55 // attr-dict `:` type($result)56 // operation ::= `math.sin` $operand (`fastmath` ``57 // $fastmath^)?58 // attr-dict `:` type($result)59 // operation ::= `math.sqrt` $operand (`fastmath` ``60 // $fastmath^)?61 // attr-dict `:` type($result)62 // operation ::= `math.tan` $operand (`fastmath` ``63 // $fastmath^)?64 // attr-dict `:` type($result)65 // operation ::= `math.tanh` $operand (`fastmath` ``66 // $fastmath^)?67 // attr-dict `:` type($result)68 // operation ::= `math.trunc` $operand (`fastmath` ``69 // $fastmath^)?70 // attr-dict `:` type($result)71 seq(choice('math.absf', 'math.atan', 'math.cbrt',72 'math.ceil', 'math.cos', 'math.erf', 'math.exp',73 'math.exp2', 'math.expm1', 'math.floor',74 'math.log', 'math.log10', 'math.log1p',75 'math.log2', 'math.round', 'math.roundeven',76 'math.rsqrt', 'math.sin', 'math.sqrt', 'math.tan',77 'math.tanh', 'math.trunc'),78 field('operand', $.value_use),79 field('fastmath', optional($.fastmath_attr)),80 field('attributes', optional($.attribute)),81 field('return', $._type_annotation)),82 83 // operation ::= `math.absi` $operand attr-dict `:`84 // type($result) operation ::= `math.ctlz` $operand attr-dict85 // `:` type($result) operation ::= `math.cttz` $operand86 // attr-dict `:` type($result) operation ::= `math.ctpop`87 // $operand attr-dict `:` type($result)88 seq(choice('math.absi', 'math.ctlz', 'math.cttz',89 'math.ctpop'),90 field('operand', $.value_use),91 field('attributes', optional($.attribute)),92 field('return', $._type_annotation)),93 94 // operation ::= `math.atan2` $lhs `,` $rhs (`fastmath` ``95 // $fastmath^)?96 // attr-dict `:` type($result)97 // operation ::= `math.copysign` $lhs `,` $rhs (`fastmath` ``98 // $fastmath^)?99 // attr-dict `:` type($result)100 // operation ::= `math.fpowi` $lhs `,` $rhs (`fastmath` ``101 // $fastmath^)?102 // attr-dict `:` type($lhs) `,` type($rhs)103 // operation ::= `math.powf` $lhs `,` $rhs (`fastmath` ``104 // $fastmath^)?105 // attr-dict `:` type($result)106 seq(choice('math.atan2', 'math.copysign', 'math.fpowi',107 'math.powf'),108 field('lhs', $.value_use), ',',109 field('rhs', $.value_use),110 field('fastmath', optional($.fastmath_attr)),111 field('attributes', optional($.attribute)),112 field('return', $._type_annotation)),113 114 // operation ::= `math.ipowi` $lhs `,` $rhs attr-dict `:`115 // type($result)116 seq('math.ipowi', field('lhs', $.value_use), ',',117 field('rhs', $.value_use),118 field('attributes', optional($.attribute)),119 field('return', $._type_annotation)),120 121 // operation ::= `math.fma` $a `,` $b `,` $c (`fastmath` ``122 // $fastmath^)?123 // attr-dict `:` type($result)124 seq('math.fma', field('a', $.value_use), ',',125 field('b', $.value_use), ',', field('c', $.value_use),126 field('fastmath', optional($.fastmath_attr)),127 field('attributes', optional($.attribute)),128 field('return', $._type_annotation)))129}130