return buf;
}
- static void substvar(buffer_t *buf, const segment seg) {
+ static void substvar(buffer_t *buf, const segment seg)
+ {
const char *res;
char tmp[STRING];
char var[STRING];
sp ::= sp SPACE .
sp ::= sp escnl SPACE .
-non_nl ::= ATOM|SPACE|BQUOTE|BSLASH|SHARP|DOLLAR|DQUOTE|EQUAL|LBRACE|QUOTE|RBRACE .
+non_nl ::= ATOM|SPACE|BQUOTE|BSLASH|SHARP|DOLLAR|DQUOTE|EQUAL|LBRACE|SQUOTE|RBRACE .
non_nl_star ::= .
non_nl_star ::= non_nl_star non_nl .
%destructor sqtok { buffer_delete(&$$); }
sqtok(Z) ::= . { Z = buffer_new(); }
sqtok(Z) ::= sqtok(A) escnl . { Z = A; }
-sqtok(Z) ::= sqtok(A) BSLASH BSLASH|QUOTE(B) . { buffer_addch(Z = A, *B.s); }
+sqtok(Z) ::= sqtok(A) BSLASH BSLASH|SQUOTE(B) . { buffer_addch(Z = A, *B.s); }
sqtok(Z) ::= sqtok(A) BSLASH ATOM|SPACE|BQUOTE|SHARP|DOLLAR|DQUOTE|EQUAL|LBRACE|RBRACE(B) . {
buffer_addch(Z = A, '\\');
buffer_add(Z, B.s, B.len);
buffer_add(Z = A, B.s, B.len);
}
+/* `-quoted tokens */
+%type bqtok { buffer_t* }
+%destructor bqtok { buffer_delete(&$$); }
+bqtok(Z) ::= . { Z = buffer_new(); }
+bqtok(Z) ::= bqtok(A) escnl . { Z = A; }
+bqtok(Z) ::= bqtok(A) BSLASH non_nl(B) . { Z = buffer_escape(A, B.s, B.len); }
+bqtok(Z) ::= bqtok(A) svar(B) . { substvar(Z = A, B); }
+bqtok(Z) ::= bqtok(A) ATOM|SPACE|SHARP|EQUAL|LBRACE|RBRACE|SQUOTE|DQUOTE(B) . {
+ buffer_add(Z = A, B.s, B.len);
+}
+
/* "-quoted tokens */
%type dqtok { buffer_t* }
-%destructor dqtok { buffer_delete(&$$); }
+%destructor dqtok { buffer_delete(&$$); }
dqtok(Z) ::= . { Z = buffer_new(); }
dqtok(Z) ::= dqtok(A) escnl . { Z = A; }
dqtok(Z) ::= dqtok(A) BSLASH non_nl(B) . { Z = buffer_escape(A, B.s, B.len); }
-dqtok(Z) ::= dqtok(A) ATOM|SPACE|SHARP|EQUAL|LBRACE|RBRACE(B) . {
+dqtok(Z) ::= dqtok(A) svar(B) . { substvar(Z = A, B); }
+dqtok(Z) ::= dqtok(A) ATOM|SPACE|SHARP|EQUAL|LBRACE|RBRACE|SQUOTE(B) . {
buffer_add(Z = A, B.s, B.len);
}
-dqtok(Z) ::= dqtok(A) svar(B) . { substvar(Z = A, B); }
+dqtok(Z) ::= dqtok(A) BQUOTE bqtok(B) BQUOTE . { /* XXX */ buffer_merge(Z = A, &B); }
/* unquoted tokens */
%type uqtok { buffer_t* }
%destructor uqtok { buffer_delete(&$$); }
-uqtok(Z) ::= ATOM|EQUAL|LBRACE|RBRACE(A) . { buffer_add(Z = buffer_new(), A.s, A.len); }
uqtok(Z) ::= BSLASH non_nl(A) . { buffer_add(Z = buffer_new(), A.s, A.len); }
-uqtok(Z) ::= QUOTE sqtok(A) QUOTE . { Z = A; }
+uqtok(Z) ::= svar(A) . { substvar(Z = buffer_new(), A); }
+uqtok(Z) ::= ATOM|EQUAL|LBRACE|RBRACE(A) . { buffer_add(Z = buffer_new(), A.s, A.len); }
+uqtok(Z) ::= SQUOTE sqtok(A) SQUOTE . { Z = A; }
uqtok(Z) ::= DQUOTE dqtok(A) DQUOTE . { Z = A; }
-uqtok(Z) ::= svar(B) . { substvar(Z = buffer_new(), B); }
+uqtok(Z) ::= BQUOTE bqtok(A) BQUOTE . { /* XXX */ Z = A; }
/* token accumulator */
%type token { buffer_t* }