module.exports = grammar({ name: 'dust', rules: { source: $ => repeat(choice( $.statement, )), statement: $ => seq($.expression, $.close), expression: $ => choice( $.identifier, prec(1, $.value), prec(2, seq( choice( $.value, $.identifier, ), $.operator, choice( $.value, $.identifier, $.expression, ))), ), close: $ => ";", identifier: $ => /[a-zA-Z|_|.]+(_[a-zA-Z]+)*/, value: $ => choice( $.integer, $.float, $.string, $.list, $.empty, $.boolean, $.function, ), float: $ => /\d+\.\d*/, integer: $ => /\d+/, string: $ => /("|'|`)(.*?)("|'|`)/, function: $ => /{(.*?)}/, empty: $ => '()', boolean: $ => choice( 'true', 'false', ), list: $ => seq( '(', repeat1(seq($.value, optional(','))), ')' ), operator: $ => choice( '+', '-', '=', ), } });