Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion CMakeLists.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 19 additions & 5 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,11 +534,11 @@ module.exports = grammar({

// plain scalar schema

_r_sgl_pln_blk: $ => choice($._r_sgl_pln_nul_blk, $._r_sgl_pln_bol_blk, $._r_sgl_pln_int_blk, $._r_sgl_pln_flt_blk, $._r_sgl_pln_str_blk),
_br_sgl_pln_blk: $ => choice($._br_sgl_pln_nul_blk, $._br_sgl_pln_bol_blk, $._br_sgl_pln_int_blk, $._br_sgl_pln_flt_blk, $._br_sgl_pln_str_blk),
_b_sgl_pln_blk: $ => choice($._b_sgl_pln_nul_blk, $._b_sgl_pln_bol_blk, $._b_sgl_pln_int_blk, $._b_sgl_pln_flt_blk, $._b_sgl_pln_str_blk),
_r_sgl_pln_flw: $ => choice($._r_sgl_pln_nul_flw, $._r_sgl_pln_bol_flw, $._r_sgl_pln_int_flw, $._r_sgl_pln_flt_flw, $._r_sgl_pln_str_flw),
_br_sgl_pln_flw: $ => choice($._br_sgl_pln_nul_flw, $._br_sgl_pln_bol_flw, $._br_sgl_pln_int_flw, $._br_sgl_pln_flt_flw, $._br_sgl_pln_str_flw),
_r_sgl_pln_blk: $ => scalar_types($, 'r', 'blk'),
_br_sgl_pln_blk: $ => scalar_types($, 'br', 'blk'),
_b_sgl_pln_blk: $ => scalar_types($, 'b', 'blk'),
_r_sgl_pln_flw: $ => scalar_types($, 'r', 'flw'),
_br_sgl_pln_flw: $ => scalar_types($, 'br', 'flw'),

_r_mtl_pln_blk: $ => $._r_mtl_pln_str_blk,
_br_mtl_pln_blk: $ => $._br_mtl_pln_str_blk,
Expand Down Expand Up @@ -613,6 +613,7 @@ module.exports.grammar = global_alias(global_alias(module.exports.grammar, {
..._('boolean_scalar', '_r_sgl_pln_bol_blk', '_br_sgl_pln_bol_blk', '_b_sgl_pln_bol_blk', '_r_sgl_pln_bol_flw', '_br_sgl_pln_bol_flw'),
..._('integer_scalar', '_r_sgl_pln_int_blk', '_br_sgl_pln_int_blk', '_b_sgl_pln_int_blk', '_r_sgl_pln_int_flw', '_br_sgl_pln_int_flw'),
..._('float_scalar', '_r_sgl_pln_flt_blk', '_br_sgl_pln_flt_blk', '_b_sgl_pln_flt_blk', '_r_sgl_pln_flt_flw', '_br_sgl_pln_flt_flw'),
..._('timestamp_scalar', '_r_sgl_pln_tms_blk', '_br_sgl_pln_tms_blk', '_b_sgl_pln_tms_blk', '_r_sgl_pln_tms_flw', '_br_sgl_pln_tms_flw'),
..._('string_scalar', '_r_sgl_pln_str_blk', '_br_sgl_pln_str_blk', '_b_sgl_pln_str_blk', '_r_sgl_pln_str_flw', '_br_sgl_pln_str_flw',
'_r_mtl_pln_str_blk', '_br_mtl_pln_str_blk', '_r_mtl_pln_str_flw', '_br_mtl_pln_str_flw'),
}), {
Expand Down Expand Up @@ -714,3 +715,16 @@ function recursive_alias(rule, alias_map, checklist) {
throw new Error(`Unexpected rule type ${JSON.stringify(rule.type)}`);
}
}

/**
* @param {GrammarSymbols<string>} symbols
* @param {'r' | 'br' | 'b'} prefix
* @param {'blk' | 'flw'} suffix
*/
function scalar_types(symbols, prefix, suffix) {
const types = Array.from(
['nul', 'bol', 'int', 'flt', 'tms', 'str'],
t => symbols[`_${prefix}_sgl_pln_${t}_${suffix}`],
);
return choice(...types);
}
2 changes: 1 addition & 1 deletion schema/core/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions schema/core/src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions schema/core/src/node-types.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions schema/core/src/tree_sitter/alloc.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions schema/core/src/tree_sitter/parser.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion schema/json/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions schema/json/src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions schema/json/src/node-types.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions schema/json/src/tree_sitter/alloc.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions schema/json/src/tree_sitter/parser.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 53 additions & 0 deletions schema/legacy/grammar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/** @see {@link YAML 1.1|https://yaml.org/type/} */

/// <reference types="tree-sitter-cli/dsl" />

module.exports = grammar({
name: "core_schema",

extras: _ => [],

rules: {
scalar: $ => choice($.null, $.bool, $.int, $.float, $.timestamp),

null: _ => token(choice("~", "null", "Null", "NULL")),

bool: _ => token(choice(
"y", "Y", "yes", "Yes", "YES", "n", "N", "no", "No", "NO",
"true", "True", "TRUE", "false", "False", "FALSE",
"on", "On", "ON", "off", "Off", "OFF",
)),

int: _ => token(choice(
/[-+]?0b[0-1_]+/, // base 2
/[-+]?0[0-7_]+/, // base 8
/[-+]?(0|[1-9][0-9_]*)/, // base 10
/[-+]?0x[0-9a-fA-F_]+/, // base 16
/[-+]?[1-9][0-9_]*(:[0-5]?[0-9])+/, // base 60
)),

float: _ => token(choice(
/[-+]?([0-9][0-9_]*)?\.[0-9.]*([eE][-+][0-9]+)?/, // base 10
/[-+]?[0-9][0-9_]*(:[0-5]?[0-9])+\.[0-9_]*/, // base 60
seq(
optional(choice("-", "+")),
choice(".inf", ".Inf", ".INF")
), // infinity
choice(".nan", ".NaN", ".NAN"), // not a number
)),

timestamp: _ => token(choice(
/\d\d\d\d-\d\d-\d\d/, // ymd
seq(
/\d\d\d\d-\d\d?-\d\d?/, // year-month-day
choice("T", "t", /[ \t]+/),
/\d\d?:\d\d:\d\d/, // hour:minute:second
optional(/\.\d+/), // fraction
optional(choice(
/[ \t]*Z/,
/[-+]\d\d?(:\d\d)?/
)) // time zone
)
))
},
});
7 changes: 7 additions & 0 deletions schema/legacy/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading