Simplify String rule in parser (#2805)
Use a StringStart component that is either FORMAT QQSTRING_START or QQSTRING_START instead of having two similar rules for String. This is simpler and avoids having to use an untyped mid-rule action component to copy FORMAT at the top of the stack before QQString, and having to use jv_free($<literal>3) instead of jv_free($1) just to make bison not complain about the "unused" mid-rule component.
This commit is contained in:
1 parent
d8327a90b8
commit
dcaf701ef6
2 files changed
+691
-698
No files matched your search
Generated
+680
-687
File diff suppressed because it is too large.
Load diff
+11
-11
@@ -122,7 +122,7 @@ struct lexer_param;
|
||||
%type <blk> Param Params Arg Args
|
||||
%type <blk> Patterns RepPatterns Pattern ArrayPats ObjPats ObjPat
|
||||
%type <literal> Keyword
|
||||
%type <literal> NoFormat
|
||||
%type <literal> StringStart
|
||||
%{
|
||||
#include "lexer.h"
|
||||
struct lexer_param {
|
||||
@@ -599,20 +599,20 @@ IDENT {
|
||||
}
|
||||
|
||||
|
||||
NoFormat:
|
||||
%empty {
|
||||
StringStart:
|
||||
FORMAT QQSTRING_START {
|
||||
$$ = $1;
|
||||
} |
|
||||
QQSTRING_START {
|
||||
$$ = jv_string("text");
|
||||
}
|
||||
|
||||
|
||||
String:
|
||||
QQSTRING_START NoFormat QQString QQSTRING_END {
|
||||
$$ = $3;
|
||||
jv_free($2);
|
||||
} |
|
||||
FORMAT QQSTRING_START { $<literal>$ = $1; } QQString QQSTRING_END {
|
||||
$$ = $4;
|
||||
jv_free($<literal>3);
|
||||
}
|
||||
StringStart QQString QQSTRING_END {
|
||||
$$ = $2;
|
||||
jv_free($1);
|
||||
};
|
||||
|
||||
|
||||
QQString:
|
||||
|
||||
Reference in new issue
Block a user