UNPKG

@fink/larix

Version:

A parser for generating fink's AST.

30 lines (23 loc) 968 B
const { add_operator } = require("@fink/prattler/expressions.js"); const { prefix, infix, infix_right } = require("../expressions.js"); const arithm = token_type => infix(token_type, `arithm`); exports.arithm = arithm; const arithm_right = token_type => infix_right(token_type, `arithm:right`); exports.arithm_right = arithm_right; const add_arithmetic_operators = ctx => { let ˆpipe_result_1 = ctx; ˆpipe_result_1 = add_operator(arithm(`+`))(ˆpipe_result_1); ˆpipe_result_1 = add_operator(arithm(`-`))(ˆpipe_result_1); ˆpipe_result_1 = add_operator(prefix(`prefix_neg`, `arithm:prefix`))(ˆpipe_result_1); ˆpipe_result_1 = add_operator(arithm(`*`))(ˆpipe_result_1); ˆpipe_result_1 = add_operator(arithm(`/`))(ˆpipe_result_1); ˆpipe_result_1 = add_operator(arithm(`%`))(ˆpipe_result_1); return ˆpipe_result_1 = add_operator(arithm_right(`^`))(ˆpipe_result_1); }; exports.add_arithmetic_operators = add_arithmetic_operators;