module.exports = grammar({ name: 'dust', rules: { source: $ => repeat(choice( $.statement, )), statement: $ => choice( seq($.value, $.close), seq($.identifier, $.close), seq($.identifier, $.operator, $.statement), ), 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( '+', '-', $.assignment, ), assignment: $ => choice( '=', '+=', '-=', ), } });