2020-08-11 16:37:53 +04:00
|
|
|
let sepBy1 = (sep, p) => seq(p, repeat(seq(sep, p)))
|
|
|
|
let sepBy = (sep, p) => optional(sepBy1(sep, p))
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-17 18:33:46 +04:00
|
|
|
let some = x => seq(x, repeat(x))
|
|
|
|
|
2020-08-11 16:37:53 +04:00
|
|
|
function mkOp($, opExpr) {
|
|
|
|
return seq(
|
2020-08-17 18:33:46 +04:00
|
|
|
field("left", $._expr),
|
2020-08-11 16:37:53 +04:00
|
|
|
field("op", opExpr),
|
2020-08-17 18:33:46 +04:00
|
|
|
field("right", $._expr)
|
2020-08-11 16:37:53 +04:00
|
|
|
);
|
|
|
|
}
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-11 16:37:53 +04:00
|
|
|
module.exports = grammar({
|
|
|
|
name: 'CameLigo',
|
2020-08-17 16:29:42 +04:00
|
|
|
word: $ => $.Keyword,
|
2020-08-12 22:49:05 +04:00
|
|
|
extras: $ => [$.ocaml_comment, $.comment, /\s/],
|
2020-04-30 14:39:51 +04:00
|
|
|
|
|
|
|
rules: {
|
2020-08-17 18:33:46 +04:00
|
|
|
contract: $ => repeat(field("declaration", $._declaration)),
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-11 16:37:53 +04:00
|
|
|
_declaration: $ => choice(
|
|
|
|
$.let_decl,
|
2020-08-17 18:33:46 +04:00
|
|
|
$.fun_decl,
|
2020-08-12 22:49:05 +04:00
|
|
|
$.type_decl,
|
|
|
|
$.include,
|
2020-08-11 16:37:53 +04:00
|
|
|
),
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-17 16:29:42 +04:00
|
|
|
include: $ => seq(
|
|
|
|
'#include',
|
|
|
|
field("filename", $.String)
|
|
|
|
),
|
2020-08-12 22:49:05 +04:00
|
|
|
|
|
|
|
_attribute: $ => /\[@@[a-z]+\]/,
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-17 18:33:46 +04:00
|
|
|
fun_decl: $ => seq(
|
2020-08-11 16:37:53 +04:00
|
|
|
"let",
|
2020-08-17 18:33:46 +04:00
|
|
|
optional(field("recursive", "rec")),
|
|
|
|
field("name", $.Name),
|
|
|
|
some(field("arg", $._paren_pattern)),
|
2020-08-12 22:49:05 +04:00
|
|
|
optional(seq(
|
|
|
|
":",
|
2020-08-17 18:33:46 +04:00
|
|
|
field("type", $._type_expr)
|
2020-08-12 22:49:05 +04:00
|
|
|
)),
|
2020-08-11 16:37:53 +04:00
|
|
|
"=",
|
2020-08-17 16:29:42 +04:00
|
|
|
field("body",$._program),
|
2020-08-12 22:49:05 +04:00
|
|
|
repeat(field("attribute", $._attribute))
|
2020-08-11 16:37:53 +04:00
|
|
|
),
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-17 18:33:46 +04:00
|
|
|
let_decl: $ => seq(
|
|
|
|
"let",
|
|
|
|
optional(field("recursive", "rec")),
|
|
|
|
field("name", $._pattern),
|
|
|
|
optional(seq(
|
|
|
|
":",
|
|
|
|
field("type", $._type_expr)
|
|
|
|
)),
|
|
|
|
"=",
|
|
|
|
field("body",$._program),
|
|
|
|
repeat(field("attribute", $._attribute))
|
2020-08-11 16:37:53 +04:00
|
|
|
),
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-11 16:37:53 +04:00
|
|
|
//========== EXPR ============
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-17 16:29:42 +04:00
|
|
|
_program: $ => choice(
|
2020-08-11 16:37:53 +04:00
|
|
|
$.let_expr1,
|
|
|
|
$._expr
|
|
|
|
),
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-11 16:37:53 +04:00
|
|
|
let_expr1: $ => seq(
|
2020-08-17 18:33:46 +04:00
|
|
|
field("decl", $.let_decl),
|
2020-08-11 16:37:53 +04:00
|
|
|
"in",
|
2020-08-17 18:33:46 +04:00
|
|
|
field("body", $._program)
|
2020-08-11 16:37:53 +04:00
|
|
|
),
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-11 16:37:53 +04:00
|
|
|
// [1;2]
|
|
|
|
list_pattern: $ => seq(
|
|
|
|
"[",
|
2020-08-17 18:33:46 +04:00
|
|
|
sepBy(';', field("item", $._pattern)),
|
2020-08-11 16:37:53 +04:00
|
|
|
"]"
|
|
|
|
),
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-11 16:37:53 +04:00
|
|
|
// a :: b
|
|
|
|
list_con_pattern: $ => prec.right(9, seq(
|
2020-08-17 18:33:46 +04:00
|
|
|
field("x", $._pattern),
|
2020-08-11 16:37:53 +04:00
|
|
|
"::",
|
2020-08-17 18:33:46 +04:00
|
|
|
field("xs", $._pattern)
|
2020-08-11 16:37:53 +04:00
|
|
|
)),
|
|
|
|
|
|
|
|
// a, b, c
|
|
|
|
tup_pattern: $ => prec.right(8,seq(
|
2020-08-17 18:33:46 +04:00
|
|
|
field("item", $._pattern),
|
2020-08-11 16:37:53 +04:00
|
|
|
",",
|
2020-08-17 18:33:46 +04:00
|
|
|
sepBy1(",", field("item", $._pattern))
|
2020-08-11 16:37:53 +04:00
|
|
|
)),
|
|
|
|
|
|
|
|
_pattern: $ => choice(
|
2020-08-21 18:24:06 +04:00
|
|
|
$.var_pattern,
|
2020-08-17 18:33:46 +04:00
|
|
|
$._paren_pattern,
|
2020-08-11 16:37:53 +04:00
|
|
|
$.con_pattern,
|
|
|
|
$._literal,
|
|
|
|
$.list_pattern,
|
|
|
|
$.list_con_pattern,
|
|
|
|
$.tup_pattern,
|
|
|
|
"_"
|
|
|
|
),
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-21 18:24:06 +04:00
|
|
|
var_pattern: $ => seq(
|
|
|
|
field("var", $.Name)
|
|
|
|
),
|
|
|
|
|
2020-08-11 16:37:53 +04:00
|
|
|
con_pattern: $ => prec(10,
|
2020-04-30 14:39:51 +04:00
|
|
|
seq(
|
2020-08-17 18:33:46 +04:00
|
|
|
field("ctor", $.data_con),
|
|
|
|
optional(field("args",$._pattern))
|
2020-08-11 16:37:53 +04:00
|
|
|
)
|
|
|
|
),
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-17 18:33:46 +04:00
|
|
|
_paren_pattern: $ => choice(
|
|
|
|
$.annot_pattern,
|
|
|
|
$.paren_pattern,
|
2020-08-11 16:37:53 +04:00
|
|
|
),
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-17 18:33:46 +04:00
|
|
|
paren_pattern: $ =>
|
|
|
|
seq(
|
|
|
|
"(",
|
|
|
|
field("pat", $._pattern),
|
|
|
|
")"
|
|
|
|
),
|
|
|
|
|
|
|
|
annot_pattern: $ =>
|
|
|
|
seq(
|
|
|
|
"(",
|
|
|
|
field("pat", $._pattern),
|
|
|
|
":",
|
|
|
|
field("type", $._type_expr),
|
|
|
|
")"
|
|
|
|
),
|
|
|
|
|
|
|
|
_call: $ => choice(
|
2020-08-11 16:37:53 +04:00
|
|
|
$.unary_op_app,
|
2020-08-17 18:33:46 +04:00
|
|
|
$.binary_op_app,
|
|
|
|
),
|
2020-08-11 16:37:53 +04:00
|
|
|
|
2020-08-17 18:33:46 +04:00
|
|
|
binary_op_app: $ => choice(
|
|
|
|
prec.left(16, mkOp($, "mod")),
|
|
|
|
prec.left(15, mkOp($, choice("/", "*"))),
|
|
|
|
prec.left(14, mkOp($, choice("-", "+"))),
|
|
|
|
prec.right(13, mkOp($, "::")),
|
|
|
|
prec.right(12, mkOp($, "^")),
|
|
|
|
prec.left(11, mkOp($, choice("&&", "||"))),
|
|
|
|
prec.left(10, mkOp($, choice("=", "<>", "==", "<", "<=", ">", ">="))),
|
2020-08-11 16:37:53 +04:00
|
|
|
),
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-17 18:33:46 +04:00
|
|
|
// - a
|
|
|
|
unary_op_app: $ => prec(19, seq(
|
|
|
|
field("negate", "-"),
|
|
|
|
field("arg", $._expr)
|
|
|
|
)),
|
|
|
|
|
2020-08-11 16:37:53 +04:00
|
|
|
// f a
|
2020-08-17 18:33:46 +04:00
|
|
|
fun_app: $ => prec.left(20, seq(
|
|
|
|
field("f", $._sub_expr),
|
|
|
|
field("x", $._sub_expr)
|
|
|
|
)),
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-11 16:37:53 +04:00
|
|
|
// a.0
|
2020-08-17 18:33:46 +04:00
|
|
|
index_accessor: $ => prec.right(21, seq(
|
|
|
|
field("box", $._sub_expr),
|
|
|
|
".",
|
|
|
|
field("field", $._sub_expr)
|
|
|
|
)),
|
|
|
|
|
|
|
|
// { p with a = b; c = d }
|
|
|
|
rec_literal: $ => seq(
|
|
|
|
"{",
|
|
|
|
field("field", $.rec_assignment),
|
|
|
|
repeat(seq(";", field("field", $.rec_assignment))),
|
|
|
|
optional(";"),
|
|
|
|
"}"
|
|
|
|
),
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-11 16:37:53 +04:00
|
|
|
// { p with a = b; c = d }
|
|
|
|
rec_expr: $ => seq(
|
|
|
|
"{",
|
2020-08-17 18:33:46 +04:00
|
|
|
field("subject", $.Name),
|
|
|
|
"with",
|
|
|
|
field("field", $.rec_assignment),
|
|
|
|
repeat(seq(";", field("field", $.rec_assignment))),
|
2020-08-11 16:37:53 +04:00
|
|
|
optional(";"),
|
|
|
|
"}"
|
|
|
|
),
|
|
|
|
// a = b;
|
|
|
|
rec_assignment: $ => seq(
|
2020-08-17 18:33:46 +04:00
|
|
|
field("field", $._expr),
|
2020-08-11 16:37:53 +04:00
|
|
|
"=",
|
2020-08-17 18:33:46 +04:00
|
|
|
field("value", $._expr),
|
2020-08-11 16:37:53 +04:00
|
|
|
),
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-11 16:37:53 +04:00
|
|
|
// if a then b else c
|
2020-08-12 22:49:05 +04:00
|
|
|
if_expr: $ => prec.right(seq(
|
2020-08-11 16:37:53 +04:00
|
|
|
"if",
|
|
|
|
field("condition", $._expr),
|
|
|
|
"then",
|
2020-08-17 18:33:46 +04:00
|
|
|
field("then", $._program),
|
2020-08-12 22:49:05 +04:00
|
|
|
optional(seq(
|
|
|
|
"else",
|
2020-08-17 18:33:46 +04:00
|
|
|
field("else", $._program)
|
2020-08-12 22:49:05 +04:00
|
|
|
))
|
|
|
|
)),
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-11 16:37:53 +04:00
|
|
|
// match x with ...
|
|
|
|
match_expr: $ => prec.right(1,seq(
|
|
|
|
"match",
|
2020-08-17 18:33:46 +04:00
|
|
|
field("subject", $._expr),
|
2020-08-11 16:37:53 +04:00
|
|
|
"with",
|
|
|
|
optional('|'),
|
2020-08-17 18:33:46 +04:00
|
|
|
sepBy('|', field("alt", $.matching))
|
2020-08-11 16:37:53 +04:00
|
|
|
)),
|
|
|
|
|
|
|
|
// Dog as x -> f x
|
|
|
|
matching: $ => seq(
|
|
|
|
field("pattern", $._pattern),
|
|
|
|
"->",
|
2020-08-17 18:33:46 +04:00
|
|
|
field("body", $._program)
|
2020-08-11 16:37:53 +04:00
|
|
|
),
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-11 16:37:53 +04:00
|
|
|
lambda_expr: $ => seq(
|
|
|
|
"fun",
|
2020-08-17 18:33:46 +04:00
|
|
|
repeat1(field("arg", $._paren_pattern)),
|
2020-08-11 16:37:53 +04:00
|
|
|
"->",
|
2020-09-15 12:22:15 +04:00
|
|
|
field("body", $._program)
|
2020-08-11 16:37:53 +04:00
|
|
|
),
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-11 16:37:53 +04:00
|
|
|
list_expr: $ => seq(
|
|
|
|
"[",
|
|
|
|
sepBy(";", field("item", $._expr)),
|
|
|
|
"]"
|
|
|
|
),
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-11 16:37:53 +04:00
|
|
|
tup_expr: $ => prec.right(9,seq(
|
2020-08-17 18:33:46 +04:00
|
|
|
field("x", $._expr),
|
|
|
|
some(seq(
|
|
|
|
",",
|
|
|
|
field("x", $._expr),
|
|
|
|
)),
|
2020-08-11 16:37:53 +04:00
|
|
|
)),
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-11 16:37:53 +04:00
|
|
|
_expr: $ => choice(
|
2020-08-17 18:33:46 +04:00
|
|
|
$._call,
|
2020-08-12 22:49:05 +04:00
|
|
|
$._sub_expr,
|
2020-08-11 16:37:53 +04:00
|
|
|
$.tup_expr
|
|
|
|
),
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-12 22:49:05 +04:00
|
|
|
_sub_expr: $ => choice(
|
2020-08-11 16:37:53 +04:00
|
|
|
$.fun_app,
|
|
|
|
$.paren_expr,
|
2020-08-17 18:33:46 +04:00
|
|
|
$.annot_expr,
|
2020-08-11 16:37:53 +04:00
|
|
|
$.Name,
|
|
|
|
$.Name_Capital,
|
|
|
|
$._literal,
|
|
|
|
$.rec_expr,
|
2020-08-17 18:33:46 +04:00
|
|
|
$.rec_literal,
|
2020-08-11 16:37:53 +04:00
|
|
|
$.if_expr,
|
|
|
|
$.lambda_expr,
|
|
|
|
$.match_expr,
|
|
|
|
$.list_expr,
|
2020-08-12 22:49:05 +04:00
|
|
|
$.index_accessor,
|
|
|
|
$.block_expr,
|
|
|
|
),
|
|
|
|
|
|
|
|
block_expr: $ => seq(
|
|
|
|
"begin",
|
2020-08-17 18:33:46 +04:00
|
|
|
sepBy(";", field("item", $._program)),
|
2020-08-12 22:49:05 +04:00
|
|
|
"end",
|
2020-08-11 16:37:53 +04:00
|
|
|
),
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-11 16:37:53 +04:00
|
|
|
paren_expr: $ => seq(
|
|
|
|
"(",
|
2020-08-17 18:33:46 +04:00
|
|
|
field("expr", $._program),
|
2020-08-11 16:37:53 +04:00
|
|
|
")"
|
|
|
|
),
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-17 18:33:46 +04:00
|
|
|
annot_expr: $ => seq(
|
|
|
|
"(",
|
|
|
|
field("expr", $._program),
|
|
|
|
":",
|
|
|
|
field("type", $._type_expr),
|
|
|
|
")",
|
|
|
|
),
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-11 16:37:53 +04:00
|
|
|
//========== TYPE_EXPR ============
|
|
|
|
// t, test, string, integer
|
|
|
|
type_con: $ => $.TypeName,
|
|
|
|
// Red, Green, Blue, Cat
|
|
|
|
data_con: $ => $.Name_Capital,
|
|
|
|
// a t, (a, b) t
|
|
|
|
type_app: $ => prec(10,seq(
|
2020-04-30 14:39:51 +04:00
|
|
|
choice(
|
2020-08-17 18:33:46 +04:00
|
|
|
field("x", $._type_expr),
|
|
|
|
field("x", $.type_tuple),
|
2020-08-11 16:37:53 +04:00
|
|
|
),
|
2020-08-17 18:33:46 +04:00
|
|
|
field("f", $.type_con)
|
2020-08-11 16:37:53 +04:00
|
|
|
)),
|
2020-08-17 18:33:46 +04:00
|
|
|
|
|
|
|
type_tuple: $ => seq(
|
|
|
|
"(",
|
|
|
|
sepBy1(",", field("x", choice($._type_expr, $.String))),
|
|
|
|
")"
|
|
|
|
),
|
|
|
|
|
2020-08-11 16:37:53 +04:00
|
|
|
// string * integer
|
|
|
|
type_product: $ => prec.right(5, seq(
|
2020-08-17 18:33:46 +04:00
|
|
|
field("x", $._type_expr),
|
|
|
|
some(seq(
|
|
|
|
"*",
|
|
|
|
field("x", $._type_expr)
|
|
|
|
))
|
2020-08-11 16:37:53 +04:00
|
|
|
)),
|
|
|
|
|
|
|
|
// int -> string
|
|
|
|
type_fun: $ => prec.right(8, seq(
|
2020-08-17 18:33:46 +04:00
|
|
|
field("domain", $._type_expr),
|
2020-08-11 16:37:53 +04:00
|
|
|
"->",
|
2020-08-17 18:33:46 +04:00
|
|
|
field("codomain", $._type_expr)
|
2020-08-11 16:37:53 +04:00
|
|
|
)),
|
|
|
|
|
2020-08-17 18:33:46 +04:00
|
|
|
_type_expr: $ => choice(
|
2020-08-11 16:37:53 +04:00
|
|
|
$.type_fun,
|
|
|
|
$.type_product,
|
|
|
|
$.type_app,
|
|
|
|
$.type_con,
|
2020-08-17 18:33:46 +04:00
|
|
|
$.type_tuple,
|
2020-08-11 16:37:53 +04:00
|
|
|
),
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-11 16:37:53 +04:00
|
|
|
// Cat of string, Person of string * string
|
|
|
|
variant: $ => seq(
|
|
|
|
field("constructor", $.data_con),
|
|
|
|
optional(seq(
|
|
|
|
"of",
|
2020-08-17 18:33:46 +04:00
|
|
|
field("type", $._type_expr)
|
2020-08-11 16:37:53 +04:00
|
|
|
))
|
|
|
|
),
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-11 16:37:53 +04:00
|
|
|
// Cat of string | Personn of string * string
|
|
|
|
type_sum: $ => seq(
|
2020-08-12 22:49:05 +04:00
|
|
|
optional('|'),
|
2020-08-11 16:37:53 +04:00
|
|
|
sepBy1('|', field("variant", $.variant)),
|
|
|
|
),
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-11 16:37:53 +04:00
|
|
|
// field : string * int
|
|
|
|
_label: $ => $.FieldName,
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-11 16:37:53 +04:00
|
|
|
type_rec_field: $ => seq(
|
2020-08-17 18:33:46 +04:00
|
|
|
field("field", $._label),
|
2020-08-11 16:37:53 +04:00
|
|
|
":",
|
2020-08-17 18:33:46 +04:00
|
|
|
field("type", $._type_expr)
|
2020-08-11 16:37:53 +04:00
|
|
|
),
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-11 16:37:53 +04:00
|
|
|
// { field1 : a; field2 : b }
|
|
|
|
type_rec: $ => seq(
|
|
|
|
"{",
|
2020-08-17 18:33:46 +04:00
|
|
|
sepBy(";", field("field", $.type_rec_field)),
|
2020-08-11 16:37:53 +04:00
|
|
|
optional(";"),
|
|
|
|
"}"
|
|
|
|
),
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-17 18:33:46 +04:00
|
|
|
_type_def_body: $ => choice(
|
2020-08-11 16:37:53 +04:00
|
|
|
$.type_sum,
|
2020-08-17 18:33:46 +04:00
|
|
|
$._type_expr,
|
2020-08-11 16:37:53 +04:00
|
|
|
$.type_rec
|
|
|
|
),
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-11 16:37:53 +04:00
|
|
|
type_decl: $ => seq(
|
|
|
|
"type",
|
2020-08-17 18:33:46 +04:00
|
|
|
field("name", $.type_con),
|
|
|
|
"=",
|
|
|
|
field("type", $._type_def_body)
|
2020-04-30 14:39:51 +04:00
|
|
|
),
|
|
|
|
|
2020-08-11 16:37:53 +04:00
|
|
|
_literal: $ => choice(
|
|
|
|
$.String,
|
|
|
|
$.Int,
|
|
|
|
$.Nat,
|
|
|
|
$.Tez,
|
|
|
|
$.Bytes,
|
|
|
|
$.True,
|
|
|
|
$.False,
|
|
|
|
$.Unit
|
|
|
|
),
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-11 16:37:53 +04:00
|
|
|
String: $ => /\"(\\.|[^"])*\"/,
|
|
|
|
Int: $ => /-?([1-9][0-9_]*|0)/,
|
|
|
|
Nat: $ => /([1-9][0-9_]*|0)n/,
|
|
|
|
Tez: $ => /([1-9][0-9_]*|0)(\.[0-9_]+)?(tz|tez|mutez)/,
|
|
|
|
Bytes: $ => /0x[0-9a-fA-F]+/,
|
|
|
|
Name: $ => /[a-z][a-zA-Z0-9_]*/,
|
|
|
|
TypeName: $ => /[a-z][a-zA-Z0-9_]*/,
|
|
|
|
FieldName: $ => /[a-z][a-zA-Z0-9_]*/,
|
2020-04-30 14:39:51 +04:00
|
|
|
Name_Capital: $ => /[A-Z][a-zA-Z0-9_]*/,
|
2020-08-11 16:37:53 +04:00
|
|
|
Keyword: $ => /[A-Za-z][a-z]*/,
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-11 16:37:53 +04:00
|
|
|
False: $ => 'false',
|
|
|
|
True: $ => 'true',
|
|
|
|
Unit: $ => '()',
|
2020-04-30 14:39:51 +04:00
|
|
|
|
2020-08-12 22:49:05 +04:00
|
|
|
comment: $ => /\/\/(\*\)[^\n]|\*[^\)\n]|[^\*\n])*\n/,
|
|
|
|
|
2020-08-11 16:37:53 +04:00
|
|
|
ocaml_comment: $ =>
|
|
|
|
seq(
|
|
|
|
'(*',
|
|
|
|
repeat(choice(
|
|
|
|
$.ocaml_comment,
|
2020-08-12 22:49:05 +04:00
|
|
|
/[^\*\(]/,
|
|
|
|
/\*[^\)]/,
|
|
|
|
/\([^\*]/,
|
2020-08-11 16:37:53 +04:00
|
|
|
)),
|
2020-08-12 22:49:05 +04:00
|
|
|
/\*+\)/
|
2020-08-11 16:37:53 +04:00
|
|
|
),
|
2020-04-30 14:39:51 +04:00
|
|
|
}
|
2020-08-11 16:37:53 +04:00
|
|
|
});
|