aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--boot/lexer.ll1
-rw-r--r--testsuite/compilable/comments.elna (renamed from testsuite/compilable/trailing_text.elna)7
-rw-r--r--testsuite/fail_compilation/case_type_mismatch.elna2
-rw-r--r--tools/tree-sitter/grammar.js5
-rw-r--r--tools/tree-sitter/test/corpus/comments.txt (renamed from tools/tree-sitter/test/corpus/trailing_text.txt)13
5 files changed, 24 insertions, 4 deletions
diff --git a/boot/lexer.ll b/boot/lexer.ll
index 4452956..c6a5498 100644
--- a/boot/lexer.ll
+++ b/boot/lexer.ll
@@ -76,6 +76,7 @@ EXPONENT [eE][+-]?[[:digit:]]+
return yy::parser::make_YYEOF(this->location);
}
}
+--[^\n]* ;
\(\* {
this->comment_start = this->location;
BEGIN(IN_COMMENT);
diff --git a/testsuite/compilable/trailing_text.elna b/testsuite/compilable/comments.elna
index 0a95516..502ac21 100644
--- a/testsuite/compilable/trailing_text.elna
+++ b/testsuite/compilable/comments.elna
@@ -1,5 +1,12 @@
module
+(*
+ This is multi-line
+ docblock
+*)
+
+-- This is a single-line comment.
+
end.
Everything after the module terminator is ignored and is never scanned, so it
diff --git a/testsuite/fail_compilation/case_type_mismatch.elna b/testsuite/fail_compilation/case_type_mismatch.elna
index f2db7e7..10e55ab 100644
--- a/testsuite/fail_compilation/case_type_mismatch.elna
+++ b/testsuite/fail_compilation/case_type_mismatch.elna
@@ -4,7 +4,7 @@ var
begin
case x of
- 1: (* ok *)
+ 1:
| true: (* @Error Invalid operands of type 'Int' and 'Bool' for operator = *)
end
end.
diff --git a/tools/tree-sitter/grammar.js b/tools/tree-sitter/grammar.js
index b7129df..a43c947 100644
--- a/tools/tree-sitter/grammar.js
+++ b/tools/tree-sitter/grammar.js
@@ -43,7 +43,10 @@ module.exports = grammar({
trailing_content: $ => token(seq(/[^\s]/, repeat(/[\s\S]/))),
- comment: $ => token(seq('(*', /[^*]*\*+([^)*][^*]*\*+)*/, ')')),
+ comment: $ => token(choice(
+ seq('(*', /[^*]*\*+([^)*][^*]*\*+)*/, ')'),
+ seq('--', /[^\n]*/),
+ )),
identifier: $ => /[A-Za-z_][A-Za-z0-9_]*/,
diff --git a/tools/tree-sitter/test/corpus/trailing_text.txt b/tools/tree-sitter/test/corpus/comments.txt
index bb39c86..8c933ea 100644
--- a/tools/tree-sitter/test/corpus/trailing_text.txt
+++ b/tools/tree-sitter/test/corpus/comments.txt
@@ -1,9 +1,16 @@
==================
-trailing_text
+comments
==================
module
+(*
+ This is multi-line
+ dockblock
+*)
+
+-- This is a one-line comment.
+
end.
Everything after the module terminator is ignored and is never scanned, so it
@@ -12,5 +19,7 @@ does not have to be Elna: proc 1 2 3 "unterminated
---
(source_file
- (module_declaration)
+ (module_declaration
+ (comment)
+ (comment))
(trailing_content))