From 39f31b901dd3f77f33ad7d047ac78d2b94d7ca1d Mon Sep 17 00:00:00 2001 From: ProgramSnail Date: Fri, 21 Jul 2023 14:11:13 +0300 Subject: [PATCH] exec comments added (for shell) --- corpus/test.langexp | 4 +++- grammar.g4 | 1 + grammar.js | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/corpus/test.langexp b/corpus/test.langexp index d878682..f7fdf18 100644 --- a/corpus/test.langexp +++ b/corpus/test.langexp @@ -2,6 +2,8 @@ Test ================================================================================ +#! lang + :: module; // import module to current namespace :: _ = module; // import module to current namespace and use functions inside without namespace @@ -11,7 +13,7 @@ Test func = { - @=> { + @ => { %x := scan; ?? x == ''x'' => break; }; diff --git a/grammar.g4 b/grammar.g4 index 9d3263d..cdb4c1a 100644 --- a/grammar.g4 +++ b/grammar.g4 @@ -144,6 +144,7 @@ literal: FLOAT_NUMBER_LITERAL DEFINITION_INFO : : ': ' ([^\n]*)+ ; ANNOTATION_INFO : ANNOTATION_IDENTIFIER [^\n]* ; +LINE_COMMENT : '#!' [^\n]* -> skip ; LINE_COMMENT : '//' [^\n]* -> skip ; BLOCK_COMMENT : '\*' ([^*] |('\*' [^/]))* '*/' -> skip ; diff --git a/grammar.js b/grammar.js index fd9e903..924520e 100644 --- a/grammar.js +++ b/grammar.js @@ -4,6 +4,7 @@ module.exports = grammar({ word: $ => $.identifier, extras: $ => [ + $._exec_comment, $._line_comment, $._block_comment, /\s/ @@ -240,6 +241,7 @@ module.exports = grammar({ definition_info: $ => repeat1(seq(': ', /[^\n]*/)), annotation_info: $ => seq($.annotation_identifier, /[^\n]*/), + _exec_comment: $ => token(seq('#!', /[^\n]*/)), _line_comment: $ => token(seq('//', /[^\n]*/)), _block_comment: $ => token(seq('/*', /([^*]|(\*[^/]))*/, '*/')),