add conditionals

This commit is contained in:
mhoffm
2021-06-12 21:47:30 +02:00
parent 0b8859a794
commit 22b921f405
5 changed files with 2899 additions and 2407 deletions

View File

@@ -11,6 +11,7 @@ module.exports = grammar({
[$.object_elem, $.variable_expr],
[$.attr_splat],
[$.full_splat],
[$.conditional],
],
extras: $ => [
@@ -51,7 +52,7 @@ module.exports = grammar({
expression: $ => choice(
$.expr_term,
//$.operation,
//$.conditional,
$.conditional,
),
expr_term: $ => choice(
@@ -172,6 +173,14 @@ module.exports = grammar({
ellipsis: $ => token('...'),
conditional: $ => seq(
$.expression,
'?',
$.expression,
':',
$.expression,
),
// http://stackoverflow.com/questions/13014947/regex-to-match-a-c-style-multiline-comment/36328890#36328890
comment: $ => token(choice(
seq('#', /.*/),