aboutsummaryrefslogtreecommitdiff
path: root/spec/test/tree.vartan
diff options
context:
space:
mode:
authorRyo Nihei <nihei.dev@gmail.com>2022-06-13 00:47:45 +0900
committerRyo Nihei <nihei.dev@gmail.com>2022-06-13 00:47:45 +0900
commit4b2cf7bc03efe6c4fc0b19ca5da071583bdcb900 (patch)
treeb68645aec68fe642de11992cda1b2f6123d6b6d4 /spec/test/tree.vartan
parentProhibit using a pattern in an alternative (diff)
downloadurubu-4b2cf7bc03efe6c4fc0b19ca5da071583bdcb900.tar.gz
urubu-4b2cf7bc03efe6c4fc0b19ca5da071583bdcb900.tar.xz
Support testing token's texts in vartan-test command
Diffstat (limited to 'spec/test/tree.vartan')
-rw-r--r--spec/test/tree.vartan62
1 files changed, 62 insertions, 0 deletions
diff --git a/spec/test/tree.vartan b/spec/test/tree.vartan
index 139014d..aa8f733 100644
--- a/spec/test/tree.vartan
+++ b/spec/test/tree.vartan
@@ -7,6 +7,7 @@
tree
: l_paren identifier tree_list r_paren #ast identifier tree_list...
+ | l_paren identifier string r_paren #ast identifier string
| l_paren error r_paren #recover #ast error
;
tree_list
@@ -14,6 +15,41 @@ tree_list
| tree
| #prec $empty_tree
;
+string
+ : raw_string
+ | interpreted_string
+ ;
+raw_string
+ : raw_string_open opt_raw_string_body raw_string_close #ast opt_raw_string_body...
+ ;
+opt_raw_string_body
+ : raw_string_body
+ |
+ ;
+interpreted_string
+ : interpreted_string_open opt_interpreted_string_body interpreted_string_close #ast opt_interpreted_string_body...
+ | interpreted_string_open error interpreted_string_close #recover #ast error
+ ;
+opt_interpreted_string_body
+ : interpreted_string_body #ast interpreted_string_body...
+ |
+ ;
+interpreted_string_body
+ : interpreted_string_body interpreted_string_elem #ast interpreted_string_body... interpreted_string_elem...
+ | interpreted_string_elem #ast interpreted_string_elem...
+ ;
+interpreted_string_elem
+ : interpreted_seq
+ | l_brace
+ | r_brace
+ | hex_digits
+ | escaped_seq
+ | escape_char
+ | codepoint_expr
+ ;
+codepoint_expr
+ : codepoint_prefix l_brace hex_digits r_brace #ast hex_digits
+ ;
ws #skip
: "[\u{0009}\u{000A}\u{000D}\u{0020}]+";
@@ -23,3 +59,29 @@ r_paren
: ')';
identifier
: "[0-9A-Za-z_]+";
+
+raw_string_open #push raw_string
+ : "'";
+raw_string_body #mode raw_string
+ : "[^']+";
+raw_string_close #mode raw_string #pop
+ : "'";
+
+interpreted_string_open #push interpreted_string
+ : '"';
+interpreted_seq #mode interpreted_string
+ : "[^\"\\{}0-9A-Fa-f]+";
+codepoint_prefix #mode interpreted_string
+ : '\u';
+l_brace #mode interpreted_string
+ : '{';
+r_brace #mode interpreted_string
+ : '}';
+hex_digits #mode interpreted_string
+ : "[0-9A-Fa-f]+";
+escaped_seq #mode interpreted_string
+ : "\\[\"\\]";
+escape_char #mode interpreted_string
+ : '\';
+interpreted_string_close #mode interpreted_string #pop
+ : '"';