2022-12-09 12:36:31 +03:00
|
|
|
const PREC = {
|
|
|
|
COMMENT: -2,
|
|
|
|
EOL: -1,
|
2022-12-09 16:08:41 +03:00
|
|
|
TEXT_BLOCK_CONTENT: -1,
|
2022-12-09 18:49:33 +03:00
|
|
|
UNQUOTED_STRING: -1,
|
2022-12-09 12:36:31 +03:00
|
|
|
CONTAINER: 2,
|
|
|
|
CONNECTION: 2,
|
|
|
|
SHAPE: 3,
|
2023-06-16 00:43:30 +03:00
|
|
|
CLASSES: 4,
|
2022-12-09 12:36:31 +03:00
|
|
|
IDENTIFIER: 0,
|
|
|
|
ARROW: 0,
|
|
|
|
ATTRIBUTE: 0,
|
|
|
|
ATTRIBUTE_KEY: 0,
|
|
|
|
};
|
2022-12-06 10:32:04 +03:00
|
|
|
|
2023-06-16 06:37:19 +03:00
|
|
|
// mkWrapCont :: string -> string -> ($ -> Rule) -> $ -> Rule
|
|
|
|
const mkWrapCont = (start, end) => (onDefinition) => ($) =>
|
|
|
|
seq(
|
|
|
|
start,
|
|
|
|
repeat(choice($._eol, seq(onDefinition($), $._end))),
|
|
|
|
optional(seq(onDefinition($), optional($._end))),
|
|
|
|
end
|
|
|
|
);
|
|
|
|
const mkBlock = mkWrapCont("{", "}");
|
|
|
|
const mkList = mkWrapCont("[", "]");
|
|
|
|
|
|
|
|
// mkAlias :: ($ -> Rule) -> ($ -> Rule) -> $ -> Rule
|
|
|
|
const mkAlias = (onAlias) => (onValue) => ($) => alias(onValue($), onAlias($));
|
|
|
|
const attrKeyAlias = mkAlias(($) => $.attr_key);
|
|
|
|
const attrAlias = mkAlias(($) => $.attribute);
|
|
|
|
|
|
|
|
// mkAttrCont :: ($ -> Rule) -> ($ -> Rule) -> $ -> Rule
|
|
|
|
const mkAttrCont = (onValue) => (onKey) => ($) =>
|
|
|
|
seq(onKey($), $._colon, onValue($));
|
|
|
|
const mkBaseAttr = (onKey) =>
|
|
|
|
mkAttrCont(($) => $.attr_value)(attrKeyAlias(onKey));
|
|
|
|
|
2022-12-04 00:07:26 +03:00
|
|
|
module.exports = grammar({
|
|
|
|
name: "d2",
|
|
|
|
|
2022-12-10 22:56:41 +03:00
|
|
|
externals: ($) => [
|
|
|
|
$._text_block_start,
|
|
|
|
$._text_block_end,
|
|
|
|
$._text_block_raw_text,
|
2022-12-13 11:26:52 +03:00
|
|
|
$.block_comment,
|
2022-12-10 22:56:41 +03:00
|
|
|
],
|
2022-12-09 18:21:55 +03:00
|
|
|
|
2022-12-09 12:36:31 +03:00
|
|
|
extras: ($) => [
|
|
|
|
/[ \f\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]/,
|
|
|
|
$.line_comment,
|
2022-12-13 11:26:52 +03:00
|
|
|
$.block_comment,
|
2022-12-09 12:36:31 +03:00
|
|
|
],
|
2022-12-05 11:36:14 +03:00
|
|
|
|
2022-12-13 16:41:34 +03:00
|
|
|
conflicts: ($) => [
|
|
|
|
[$._connection_path, $.container],
|
|
|
|
[$._container_block],
|
|
|
|
[$._connection_block],
|
|
|
|
[$._style_attribute_block],
|
2023-06-16 00:43:30 +03:00
|
|
|
[$._classes_block],
|
|
|
|
[$._classes_item_block],
|
|
|
|
[$.class_list],
|
2023-06-16 06:37:19 +03:00
|
|
|
[$._text_block_attrs],
|
2022-12-13 16:41:34 +03:00
|
|
|
],
|
2022-12-06 10:32:04 +03:00
|
|
|
|
2022-12-04 00:07:26 +03:00
|
|
|
rules: {
|
2022-12-07 23:14:25 +03:00
|
|
|
source_file: ($) => repeat($._root_definition),
|
2022-12-04 00:07:26 +03:00
|
|
|
|
2022-12-07 23:14:25 +03:00
|
|
|
_root_definition: ($) =>
|
|
|
|
choice(
|
2022-12-09 12:36:31 +03:00
|
|
|
$._eol,
|
|
|
|
seq(
|
|
|
|
choice(
|
|
|
|
alias($._root_attribute, $.attribute),
|
2023-06-16 00:43:30 +03:00
|
|
|
$.classes,
|
2022-12-09 12:36:31 +03:00
|
|
|
$.shape,
|
|
|
|
$.container,
|
|
|
|
$.connection
|
|
|
|
),
|
2022-12-09 12:54:11 +03:00
|
|
|
choice($._end, "\0")
|
2022-12-09 12:36:31 +03:00
|
|
|
)
|
2022-12-07 23:14:25 +03:00
|
|
|
),
|
2022-12-04 00:07:26 +03:00
|
|
|
|
2022-12-09 12:36:31 +03:00
|
|
|
// connections
|
|
|
|
|
2022-12-04 00:07:26 +03:00
|
|
|
connection: ($) =>
|
2022-12-04 03:25:38 +03:00
|
|
|
seq(
|
2022-12-09 12:36:31 +03:00
|
|
|
$._connection_path,
|
|
|
|
repeat1(seq($.arrow, $._connection_path)),
|
2022-12-09 14:09:39 +03:00
|
|
|
optional(
|
|
|
|
seq(
|
|
|
|
optional(seq($._colon, optional($.label))),
|
|
|
|
optional(seq(alias($._connection_block, $.block)))
|
|
|
|
)
|
|
|
|
)
|
2022-12-04 03:25:38 +03:00
|
|
|
),
|
2022-12-04 00:07:26 +03:00
|
|
|
|
2022-12-09 12:36:31 +03:00
|
|
|
_connection_path: ($) =>
|
2022-12-04 03:36:46 +03:00
|
|
|
seq(
|
2022-12-09 12:36:31 +03:00
|
|
|
repeat(
|
|
|
|
prec(PREC.CONNECTION, seq(alias($.shape_key, $.container_key), $.dot))
|
|
|
|
),
|
|
|
|
$.shape_key
|
|
|
|
),
|
|
|
|
|
2023-06-16 00:58:51 +03:00
|
|
|
_connection_block: mkBlock(($) => $._connection_attribute),
|
2022-12-09 14:09:39 +03:00
|
|
|
|
2023-06-16 00:43:30 +03:00
|
|
|
// classes
|
|
|
|
|
|
|
|
classes: ($) =>
|
|
|
|
prec(
|
|
|
|
PREC.CLASSES,
|
|
|
|
seq(
|
|
|
|
$.keyword_classes,
|
|
|
|
choice(
|
|
|
|
optional(seq($.dot, $._classes_item)),
|
|
|
|
seq(
|
|
|
|
optional(seq($._colon, optional($.label))),
|
|
|
|
optional(alias($._classes_block, $.block))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
),
|
|
|
|
|
2023-06-16 00:58:51 +03:00
|
|
|
_classes_block: mkBlock(($) => $._classes_item),
|
2023-06-16 00:43:30 +03:00
|
|
|
|
|
|
|
_classes_item: ($) =>
|
|
|
|
seq(
|
|
|
|
$._class_name,
|
|
|
|
choice(
|
|
|
|
optional(seq($.dot, $._shape_attribute)),
|
|
|
|
seq(
|
|
|
|
optional(seq($._colon, optional($.label))),
|
|
|
|
optional(alias($._classes_item_block, $.class_block))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
),
|
|
|
|
|
2023-06-16 00:58:51 +03:00
|
|
|
_classes_item_block: mkBlock(($) => $._classes_item_attribute),
|
2023-06-16 00:43:30 +03:00
|
|
|
|
2023-06-16 06:37:19 +03:00
|
|
|
_classes_item_attribute: attrAlias(($) =>
|
|
|
|
choice($._base_shape_attribute, $._style_attribute)
|
|
|
|
),
|
2023-06-16 00:43:30 +03:00
|
|
|
|
2022-12-09 12:36:31 +03:00
|
|
|
// containers
|
|
|
|
|
|
|
|
container: ($) =>
|
|
|
|
prec(
|
|
|
|
PREC.CONTAINER,
|
|
|
|
seq(
|
|
|
|
alias($.shape_key, $.container_key),
|
2022-12-06 12:32:50 +03:00
|
|
|
choice(
|
2022-12-09 12:36:31 +03:00
|
|
|
seq($.dot, choice($.shape, $.container)),
|
2022-12-06 12:32:50 +03:00
|
|
|
seq(
|
2022-12-09 14:09:39 +03:00
|
|
|
optional(seq($._colon, optional($.label))),
|
2023-06-16 00:43:30 +03:00
|
|
|
optional(alias($._container_block, $.block))
|
2022-12-06 12:32:50 +03:00
|
|
|
)
|
|
|
|
)
|
2022-12-09 12:36:31 +03:00
|
|
|
)
|
2022-12-04 03:36:46 +03:00
|
|
|
),
|
|
|
|
|
2023-06-16 00:58:51 +03:00
|
|
|
_container_block: mkBlock(($) => $._container_block_definition),
|
2022-12-08 01:15:09 +03:00
|
|
|
|
2022-12-09 12:36:31 +03:00
|
|
|
_container_block_definition: ($) =>
|
2022-12-13 16:41:34 +03:00
|
|
|
choice($.shape, $.container, $.connection, $._shape_attribute),
|
2022-12-07 23:14:25 +03:00
|
|
|
|
2022-12-09 12:36:31 +03:00
|
|
|
// shapes
|
2022-12-08 01:37:35 +03:00
|
|
|
|
2022-12-09 12:36:31 +03:00
|
|
|
shape: ($) =>
|
|
|
|
prec(
|
|
|
|
PREC.SHAPE,
|
|
|
|
seq(
|
|
|
|
$.shape_key,
|
|
|
|
optional(
|
|
|
|
choice(
|
2023-06-16 00:43:30 +03:00
|
|
|
seq($.dot, $._shape_attribute),
|
2023-06-16 06:37:19 +03:00
|
|
|
seq(
|
|
|
|
$._colon,
|
|
|
|
choice(
|
|
|
|
$.label,
|
|
|
|
seq(
|
|
|
|
$.text_block,
|
|
|
|
optional(alias($._text_block_attrs, $.block))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
2022-12-09 12:36:31 +03:00
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
),
|
|
|
|
|
2023-06-16 07:42:49 +03:00
|
|
|
shape_key: ($) => choice($.keyword_underscore, $.string, $._identifier),
|
2022-12-05 10:09:14 +03:00
|
|
|
|
2022-12-09 12:36:31 +03:00
|
|
|
_identifier: ($) =>
|
2022-12-09 23:44:43 +03:00
|
|
|
seq(
|
2023-01-05 16:28:22 +03:00
|
|
|
choice(/[\w\d$-]/, $.escape_sequence),
|
2022-12-09 23:44:43 +03:00
|
|
|
repeat(
|
2023-01-05 16:28:22 +03:00
|
|
|
choice(
|
|
|
|
$.escape_sequence,
|
|
|
|
token(prec(PREC.IDENTIFIER, /([\w\d'"$(),]+)?( +|-)[\w\d'"$()]+/))
|
|
|
|
)
|
2022-12-09 23:44:43 +03:00
|
|
|
),
|
|
|
|
optional(/[\w\d'"$()]+/),
|
|
|
|
optional($._dash)
|
2022-12-09 15:02:21 +03:00
|
|
|
),
|
2022-12-09 12:36:31 +03:00
|
|
|
|
2022-12-09 16:08:41 +03:00
|
|
|
text_block: ($) =>
|
2022-12-10 23:09:11 +03:00
|
|
|
seq(
|
|
|
|
alias($._text_block_start, "|"),
|
|
|
|
optional($.language),
|
|
|
|
/\s/,
|
|
|
|
alias($._text_block_raw_text, $.raw_text),
|
|
|
|
alias($._text_block_end, "|")
|
2022-12-09 18:21:55 +03:00
|
|
|
),
|
2022-12-09 16:08:41 +03:00
|
|
|
|
2023-06-16 06:37:19 +03:00
|
|
|
_text_block_attrs: mkBlock(attrAlias(($) => $._text_shape_attribute)),
|
|
|
|
|
2022-12-09 16:08:41 +03:00
|
|
|
language: ($) => /\w+/,
|
|
|
|
|
2022-12-09 12:36:31 +03:00
|
|
|
// attributes
|
2022-12-04 23:45:53 +03:00
|
|
|
|
2023-06-16 06:37:19 +03:00
|
|
|
_root_attribute: mkBaseAttr(($) => $._root_attr_key),
|
2022-12-09 12:36:31 +03:00
|
|
|
|
|
|
|
_root_attr_key: ($) =>
|
2022-12-07 18:52:19 +03:00
|
|
|
choice(
|
2022-12-09 12:36:31 +03:00
|
|
|
"direction",
|
2023-06-14 09:07:37 +03:00
|
|
|
$._grid_attr_key,
|
2022-12-09 12:36:31 +03:00
|
|
|
// reserved but doesn't affected for root
|
|
|
|
alias(
|
|
|
|
choice(
|
|
|
|
"shape",
|
|
|
|
"label",
|
|
|
|
"constraint",
|
|
|
|
"icon",
|
2023-06-16 00:43:30 +03:00
|
|
|
$.keyword_style,
|
2022-12-09 12:36:31 +03:00
|
|
|
$._common_style_attr_key,
|
|
|
|
$._text_attr_key
|
|
|
|
),
|
|
|
|
$.reserved
|
|
|
|
)
|
2022-12-07 18:52:19 +03:00
|
|
|
),
|
2022-12-04 23:45:53 +03:00
|
|
|
|
2023-06-16 06:37:19 +03:00
|
|
|
_shape_attribute: attrAlias(($) =>
|
|
|
|
choice($._class_attribute, $._base_shape_attribute, $._style_attribute)
|
|
|
|
),
|
2022-12-06 12:32:50 +03:00
|
|
|
|
2023-06-16 06:37:19 +03:00
|
|
|
_class_attribute: mkAttrCont(($) => choice($.class_list, $._class_name))(
|
|
|
|
($) => $.keyword_class
|
|
|
|
),
|
2023-06-16 00:43:30 +03:00
|
|
|
|
2023-06-16 00:58:51 +03:00
|
|
|
class_list: mkList(($) => $._class_name),
|
2023-06-16 00:43:30 +03:00
|
|
|
|
|
|
|
_class_name: ($) => alias($.shape_key, $.class_name),
|
|
|
|
|
2023-06-16 06:37:19 +03:00
|
|
|
_base_shape_attribute: mkBaseAttr(($) => $._shape_attr_key),
|
2022-12-06 12:32:50 +03:00
|
|
|
|
2022-12-09 12:36:31 +03:00
|
|
|
_shape_attr_key: ($) =>
|
|
|
|
prec(
|
|
|
|
PREC.ATTRIBUTE_KEY,
|
|
|
|
choice(
|
2023-02-16 23:28:34 +03:00
|
|
|
"direction",
|
2022-12-09 12:36:31 +03:00
|
|
|
"shape",
|
|
|
|
"label",
|
2023-01-05 16:53:32 +03:00
|
|
|
"link",
|
|
|
|
"tooltip",
|
2022-12-09 12:36:31 +03:00
|
|
|
// sql
|
|
|
|
"constraint",
|
|
|
|
// image
|
|
|
|
"icon",
|
|
|
|
"width",
|
2023-06-14 09:07:37 +03:00
|
|
|
"height",
|
2023-06-16 06:37:19 +03:00
|
|
|
$._text_attr_key,
|
2023-06-14 09:07:37 +03:00
|
|
|
$._grid_attr_key
|
2022-12-09 12:36:31 +03:00
|
|
|
)
|
2022-12-06 11:57:59 +03:00
|
|
|
),
|
|
|
|
|
2022-12-04 23:45:53 +03:00
|
|
|
_style_attribute: ($) =>
|
2022-12-09 12:36:31 +03:00
|
|
|
prec(
|
|
|
|
PREC.ATTRIBUTE,
|
|
|
|
seq(
|
2023-06-16 00:43:30 +03:00
|
|
|
$.keyword_style,
|
2022-12-09 12:36:31 +03:00
|
|
|
choice(
|
|
|
|
seq($.dot, alias($._inner_style_attribute, $.attribute)),
|
|
|
|
seq($._colon, alias($._style_attribute_block, $.block))
|
|
|
|
)
|
2022-12-06 11:57:59 +03:00
|
|
|
)
|
2022-12-04 23:45:53 +03:00
|
|
|
),
|
|
|
|
|
2023-06-16 06:37:19 +03:00
|
|
|
_style_attribute_block: mkBlock(attrAlias(($) => $._inner_style_attribute)),
|
2022-12-04 23:45:53 +03:00
|
|
|
|
2023-06-16 06:37:19 +03:00
|
|
|
_inner_style_attribute: mkBaseAttr(($) => $._style_attr_key),
|
2022-12-04 23:45:53 +03:00
|
|
|
|
2023-06-14 18:11:42 +03:00
|
|
|
_grid_attr_key: ($) =>
|
|
|
|
choice(
|
|
|
|
"vertical-gap",
|
|
|
|
"horizontal-gap",
|
|
|
|
"grid-gap",
|
|
|
|
"grid-columns",
|
|
|
|
"grid-rows"
|
|
|
|
),
|
2023-06-16 00:43:30 +03:00
|
|
|
|
2022-12-09 12:36:31 +03:00
|
|
|
_style_attr_key: ($) => choice($._common_style_attr_key, "3d"),
|
|
|
|
|
|
|
|
_common_style_attr_key: ($) =>
|
2022-12-04 23:45:53 +03:00
|
|
|
choice(
|
|
|
|
"opacity",
|
|
|
|
"fill",
|
2023-03-21 10:23:51 +03:00
|
|
|
"fill-pattern",
|
2022-12-04 23:45:53 +03:00
|
|
|
"stroke",
|
|
|
|
"stroke-width",
|
|
|
|
"stroke-dash",
|
|
|
|
"border-radius",
|
2023-02-16 23:28:34 +03:00
|
|
|
"double-border",
|
2023-06-16 05:20:03 +03:00
|
|
|
"font",
|
2023-02-16 23:28:34 +03:00
|
|
|
"font-size",
|
2022-12-04 23:45:53 +03:00
|
|
|
"font-color",
|
|
|
|
"shadow",
|
|
|
|
"multiple",
|
|
|
|
"animated",
|
2023-02-16 23:28:34 +03:00
|
|
|
"link",
|
|
|
|
"italic",
|
|
|
|
"bold",
|
2023-06-14 18:17:22 +03:00
|
|
|
"underline",
|
|
|
|
"text-transform"
|
2022-12-04 23:45:53 +03:00
|
|
|
),
|
|
|
|
|
2023-06-16 06:37:19 +03:00
|
|
|
_text_shape_attribute: mkBaseAttr(($) => $._text_attr_key),
|
|
|
|
|
2022-12-04 23:45:53 +03:00
|
|
|
_text_attr_key: ($) => "near",
|
|
|
|
|
2023-06-16 06:37:19 +03:00
|
|
|
_connection_attribute: attrAlias(($) =>
|
|
|
|
choice($._connection_arrowhead_attribute, $._style_attribute)
|
|
|
|
),
|
2022-12-09 14:09:39 +03:00
|
|
|
|
|
|
|
_connection_arrowhead_attribute: ($) =>
|
|
|
|
seq(
|
|
|
|
alias($._connection_arrowhead_attr_key, $.attr_key),
|
|
|
|
choice(
|
|
|
|
seq($.dot, alias($._style_attribute, $.attribute)),
|
|
|
|
seq(
|
|
|
|
optional(seq($._colon, optional($.label))),
|
|
|
|
optional(seq(alias($._container_block, $.block)))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
),
|
|
|
|
|
2023-06-16 00:58:51 +03:00
|
|
|
_connection_arrowhead_block: mkBlock(($) => $._shape_attribute),
|
2022-12-09 14:09:39 +03:00
|
|
|
|
|
|
|
_connection_arrowhead_attr_key: ($) =>
|
|
|
|
choice("source-arrowhead", "target-arrowhead"),
|
2022-12-04 18:35:50 +03:00
|
|
|
|
2023-06-16 07:42:49 +03:00
|
|
|
keyword_underscore: (_) => "_",
|
2023-06-16 00:43:30 +03:00
|
|
|
keyword_classes: (_) => "classes",
|
|
|
|
keyword_class: (_) => "class",
|
|
|
|
keyword_style: (_) => "style",
|
|
|
|
|
2022-12-09 12:36:31 +03:00
|
|
|
//
|
|
|
|
|
|
|
|
label: ($) => choice($.string, $._unquoted_string),
|
|
|
|
|
2022-12-09 18:49:33 +03:00
|
|
|
attr_value: ($) =>
|
|
|
|
seq(choice($.boolean, $.integer, $.float, $.string, $._unquoted_string)),
|
2022-12-05 00:26:24 +03:00
|
|
|
|
2022-12-09 12:36:31 +03:00
|
|
|
// --------------------------------------------
|
2022-12-04 18:35:37 +03:00
|
|
|
|
2022-12-09 12:36:31 +03:00
|
|
|
_dash: ($) => token.immediate("-"),
|
|
|
|
|
|
|
|
_colon: ($) => seq(":"),
|
2022-12-04 00:07:26 +03:00
|
|
|
|
2022-12-09 12:36:31 +03:00
|
|
|
arrow: ($) => token(prec(PREC.ARROW, choice(/-+>/, /--+/, /<-+/, /<-+>/))),
|
2022-12-06 10:32:04 +03:00
|
|
|
|
2022-12-09 12:36:31 +03:00
|
|
|
dot: ($) => token("."),
|
|
|
|
|
|
|
|
_unquoted_string: ($) =>
|
2023-01-05 16:53:09 +03:00
|
|
|
repeat1(
|
|
|
|
choice(
|
|
|
|
$.escape_sequence,
|
|
|
|
token(
|
|
|
|
prec(
|
|
|
|
PREC.UNQUOTED_STRING,
|
|
|
|
/[^'"`\\|\n\s;{}]([^\\\n;{}]*[^\\\n\s;{}])?/
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
),
|
2022-12-04 03:36:46 +03:00
|
|
|
|
2022-12-04 00:07:26 +03:00
|
|
|
string: ($) =>
|
|
|
|
choice(
|
2022-12-10 05:23:27 +03:00
|
|
|
seq(
|
|
|
|
"'",
|
2022-12-11 14:16:23 +03:00
|
|
|
alias($._unescaped_single_string_fragment, $.string_fragment),
|
2022-12-10 05:23:27 +03:00
|
|
|
"'"
|
|
|
|
),
|
|
|
|
seq(
|
|
|
|
'"',
|
|
|
|
repeat(
|
|
|
|
choice(
|
|
|
|
alias($._unescaped_double_string_fragment, $.string_fragment),
|
|
|
|
$.escape_sequence
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'"'
|
|
|
|
)
|
|
|
|
),
|
|
|
|
|
2022-12-11 14:16:23 +03:00
|
|
|
_unescaped_single_string_fragment: ($) => token.immediate(/[^'\n]+/),
|
2022-12-10 05:23:27 +03:00
|
|
|
|
|
|
|
_unescaped_double_string_fragment: ($) => token.immediate(/[^"\\\n]+/),
|
|
|
|
|
|
|
|
escape_sequence: ($) =>
|
|
|
|
token.immediate(
|
|
|
|
seq(
|
|
|
|
"\\",
|
|
|
|
choice(
|
|
|
|
/[^xu0-7]/,
|
|
|
|
/[0-7]{1,3}/,
|
|
|
|
/x[0-9a-fA-F]{2}/,
|
|
|
|
/u[0-9a-fA-F]{4}/,
|
|
|
|
/u{[0-9a-fA-F]+}/
|
|
|
|
)
|
|
|
|
)
|
2022-12-04 00:07:26 +03:00
|
|
|
),
|
2022-12-04 23:45:53 +03:00
|
|
|
|
2022-12-09 18:49:33 +03:00
|
|
|
boolean: ($) => choice("true", "false"),
|
|
|
|
|
|
|
|
integer: ($) => /[0-9]+/,
|
|
|
|
|
|
|
|
float: ($) => /[0-9]+\.[0-9]+/,
|
|
|
|
|
2022-12-09 12:36:31 +03:00
|
|
|
line_comment: ($) => token(prec(PREC.COMMENT, seq("#", /.*/))),
|
2022-12-04 23:45:53 +03:00
|
|
|
|
2022-12-09 12:36:31 +03:00
|
|
|
_eol: ($) => token(prec(PREC.EOL, "\n")),
|
|
|
|
_end: ($) => seq(choice(";", $._eol)),
|
2022-12-04 00:07:26 +03:00
|
|
|
},
|
|
|
|
});
|