Merge branch 'enlarge_ffi_syntax' into merge_ffi
[nit.git] / src / parser / nit.sablecc3xx
index 00f7c77..90ba0eb 100644 (file)
@@ -51,15 +51,18 @@ sstr_body = sstr_char*;
 
 long_str_char = str_char | cr | lf;
 
+// because no substraction in sablecc3, complex long strings are difficult to express
+ls1 = '"' '"'? ;
+ls2 = '{' '{'? ;
+ls12 = ls1? (ls2 ls1)* ls2?;
+
 long_str_part
-        = long_str_char
-        | '"' long_str_char
-        | '"' '"' long_str_char
-        | '{' long_str_char
-        | '{' '{' long_str_char
+        = ls12 long_str_char
         ;
 
 long_str_body = long_str_part*;
+lsend1 = ls2? (ls1 ls2)* '"""';
+lsend2 = ls1? (ls2 ls1)* '{{{';
 
 long_sstr_char = sstr_char | cr | lf;
 long_sstr_part
@@ -180,10 +183,10 @@ attrid = '_' lowercase letter*;
 
 number = digit+;
 float = digit* '.' digit+;
-string = '"' str_body '"' | '"' '"' '"' long_str_body '"' '"' '"' | ''' ''' ''' long_sstr_body ''' ''' ''';
-start_string = '"' str_body '{' | '"' '"' '"' long_str_body '{' '{' '{';
-mid_string = '}' str_body '{' | '}' '}' '}' long_str_body '{' '{' '{';
-end_string = '}' str_body '"' | '}' '}' '}' long_str_body '"' '"' '"';
+string = '"' str_body '"' | '"' '"' '"' long_str_body lsend1 | ''' ''' ''' long_sstr_body ''' ''' ''';
+start_string = '"' str_body '{' | '"' '"' '"' long_str_body lsend2;
+mid_string = '}' str_body '{' | '}' '}' '}' long_str_body lsend2;
+end_string = '}' str_body '"' | '}' '}' '}' long_str_body lsend1;
 char = (''' [[any - '''] - '\'] ''') | (''' '\' any ''');
 bad_string = ('"'|'}') str_body | '"' '"' '"' long_str_body | ''' ''' ''' long_sstr_body;
 bad_char = ''' '\'? any;