From: Pierre Habouzit Date: Thu, 14 Dec 2006 10:53:18 +0000 (+0100) Subject: style. X-Git-Url: http://git.madism.org/?a=commitdiff_plain;h=76f757084ec84861326ef36977c6e116da9a1432;p=apps%2Fmadmutt.git style. support ` tokens also, but needs to be better integrated. Signed-off-by: Pierre Habouzit --- diff --git a/rcparser.y b/rcparser.y index ca0bd6d..e58a75e 100644 --- a/rcparser.y +++ b/rcparser.y @@ -81,7 +81,8 @@ 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]; @@ -115,7 +116,7 @@ sp ::= SPACE . 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 . @@ -137,7 +138,7 @@ svar(Z) ::= DOLLAR LBRACE ATOM(B) RBRACE . { Z = B; } %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); @@ -146,25 +147,38 @@ sqtok(Z) ::= sqtok(A) ATOM|SPACE|BQUOTE|SHARP|DOLLAR|DQUOTE|EQUAL|LBRACE|RBRACE( 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* }