/** * Simple test grammar for build system verification */ module.exports = grammar({ name: 'test_lang', word: $ => $.identifier, rules: { // Root rule source_file: $ => repeat(choice($.statement, $.expression)), // Basic tokens identifier: $ => /[a-zA-Z_][a-zA-Z0-9_]*/, number: $ => /\d+/, string: $ => /"[^"]*"/, // Expressions expression: $ => choice( $.identifier, $.number, $.string ), // Statements statement: $ => choice( $.variable_declaration ), // Variable declaration variable_declaration: $ => seq( 'let', $.identifier, '=', $.expression, ';' ), // Comments line_comment: $ => seq('//', /[^\n]*/) }, extras: $ => [ /\s/, $.line_comment ] });