Yet more vcalendar varargs functions fixed for issue described in d20742e.
[claws.git] / src / quote_fmt_lex.l
1 %option nounput never-interactive
2
3 %{
4 /*
5  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
6  * Copyright (c) 1999-2007 by Hiroyuki Yamamoto & The Claws Mail Team
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  * 
21  */
22
23 #include "quote_fmt_lex.h"
24 #include "quote_fmt_parse.h"
25
26 %}
27
28 %option prefix="quote_fmt"
29 %option outfile="lex.yy.c"
30
31 %s S_NORMAL S_DATE
32
33 %{
34 /*
35  * see notes below.
36  */
37 int quote_fmt_firsttime = 1;
38 int line = -1;
39 int escaped_string = 0;
40 %}
41
42 %%
43
44 %{
45 /*
46  * NOTES:
47  * this lex script used to use characters also in use
48  * by strftime() (which we want to use for custom
49  * time formats in replies and templates). to circumvent
50  * this we have to play a little bit with states.
51  *
52  * these are the characters we also want to use in the
53  * %D time customizer:
54  *
55  * %a %A %b %B %c %C %d %H %I %j %m %M %p %S %w %x %y %Y %Z
56  *
57  * you can use these characters too, but don't forget to
58  * prepend them with the <S_NORMAL> state.
59  *
60  * also there is also work around for resetting the state
61  * (firsttime variable). this assumes that yylex() will
62  * always return to S_NORMAL after quote fmt parsing is
63  * done.
64  */
65 %} 
66
67 %{
68         if (quote_fmt_firsttime) {
69                 BEGIN S_NORMAL;
70                 quote_fmt_firsttime = 0;
71         }       
72 %}
73
74 <S_NORMAL>("%X"|"%cursor") /* cursor pos */ return SET_CURSOR_POS;
75 <S_NORMAL>("%A"|"%email") /* email address */ return SHOW_MAIL_ADDRESS;
76 <S_NORMAL>("%c"|"%cc") /* cc */ return SHOW_CC;
77 <S_NORMAL>("%d"|"%date") /* date */ return SHOW_DATE;
78 <S_NORMAL>("%D"|"%date_fmt") /* date */ { BEGIN S_DATE; return SHOW_DATE_EXPR; }
79 <S_NORMAL>("%f"|"%from") /* from */ return SHOW_FROM;
80 <S_NORMAL>("%F"|"%firstname") /* first name */ return SHOW_FIRST_NAME;
81 <S_NORMAL>("%i"|"%messageid") /* message-id */ return SHOW_MESSAGEID;
82 <S_NORMAL>("%I"|"%initials") /* initial of sender */ return SHOW_SENDER_INITIAL;
83 <S_NORMAL>("%m"|"%msg_no_sig") /* message with no signature */ return SHOW_MESSAGE_NO_SIGNATURE;
84 <S_NORMAL>("%M"|"%msg") /* message */ return SHOW_MESSAGE;
85 <S_NORMAL>("%n"|"%newsgroups") /* newsgroups */ return SHOW_NEWSGROUPS;
86 <S_NORMAL>("%N"|"%fullname") /* full name */ return SHOW_FULLNAME;
87 <S_NORMAL>("%L"|"%lastname") /* last name */ return SHOW_LAST_NAME;
88 <S_NORMAL>("%r"|"%references") /* references */ return SHOW_REFERENCES;
89 <S_NORMAL>("%s"|"%subject") /* subject */ return SHOW_SUBJECT;
90 <S_NORMAL>("%t"|"%to") /* to */ return SHOW_TO;
91 <S_NORMAL>("%T"|"%dict") /* current dictionary */ return SHOW_DICT;
92 <S_NORMAL>("%tags") /* tags */ return SHOW_TAGS;
93 <S_NORMAL>("%Q"|"%quoted_msg") /* quoted message */ return SHOW_QUOTED_MESSAGE;
94 <S_NORMAL>("%q"|"%quoted_msg_no_sig") /* quoted message with no signature */ return SHOW_QUOTED_MESSAGE_NO_SIGNATURE;
95 <S_NORMAL>("%af"|"%account_fullname") /* full name in compose account */ return SHOW_ACCOUNT_FULL_NAME;
96 <S_NORMAL>("%am"|"%account_email") /* mail address in compose account */ return SHOW_ACCOUNT_MAIL_ADDRESS;
97 <S_NORMAL>("%an"|"%account_name") /* compose account name itself */ return SHOW_ACCOUNT_NAME;
98 <S_NORMAL>("%ao"|"%account_org") /* organization in compose account */ return SHOW_ACCOUNT_ORGANIZATION;
99 <S_NORMAL>("%as"|"%account_sig") /* signature in compose account */ return SHOW_ACCOUNT_SIG;
100 <S_NORMAL>("%asp"|"%account_sigpath") /* signature path in compose account */ return SHOW_ACCOUNT_SIGPATH;
101 <S_NORMAL>("%aT"|"%account_dict") /* main dict (if enabled) in compose account */ return SHOW_ACCOUNT_DICT;
102 <S_NORMAL>("%ABc"|"%addrbook_cc") /* completion of 'Cc' from the address book */ return SHOW_ADDRESSBOOK_COMPLETION_FOR_CC;
103 <S_NORMAL>("%ABf"|"%addrbook_from") /* completion of 'From' from the address book */ return SHOW_ADDRESSBOOK_COMPLETION_FOR_FROM;
104 <S_NORMAL>("%ABt"|"%addrbook_to") /* completion of 'To' from the address book */ return SHOW_ADDRESSBOOK_COMPLETION_FOR_TO;
105 "\\\%" /* % */ return SHOW_PERCENT;
106 "\\\\" /* \ */ return SHOW_BACKSLASH;
107 "\\t"|"\t" /* tab */ return SHOW_TAB;
108 "\n" /* return */ { line++; return SHOW_EOL; }
109 "\\n" /* escaped return */ { if (escaped_string) line++; return SHOW_EOL; }
110 "\\?" /* ? */ return SHOW_QUESTION_MARK;
111 "\\!" return SHOW_EXCLAMATION_MARK;
112 "\\|" return SHOW_PIPE;
113 "\\{" return SHOW_OPARENT;
114 "\\}" return SHOW_CPARENT;
115 ("?d"|"?date") /* query date */ return QUERY_DATE;
116 ("?f"|"?from") /* query from */ return QUERY_FROM;
117 ("?N"|"?F"|"?L"|"?I"|"?fullname"|"?firstname"|"?lastname"|"?initials") /* query from name */ return QUERY_FULLNAME;
118 ("?s"|"?subject") /* query subject */ return QUERY_SUBJECT;
119 ("?t"|"?to") /* query to */ return QUERY_TO;
120 ("?T"|"?dict") /* query current dictionary set and enabled */ return QUERY_DICT;
121 ("?c"|"?cc") /* query cc */ return QUERY_CC;
122 ("?n"|"?newsgroups") /* query newsgroups */ return QUERY_NEWSGROUPS;
123 ("?i"|"?messageid") /* query message-id */ return QUERY_MESSAGEID;
124 ("?r"|"?references") /* query references */ return QUERY_REFERENCES;
125 ("?af"|"?account_fullname") /* query full name in compose account */ return QUERY_ACCOUNT_FULL_NAME;
126 ("?ao"|"?account_org") /* query organization in compose account */ return QUERY_ACCOUNT_ORGANIZATION;
127 ("?as"|"?account_sig") /* query signature */ return QUERY_ACCOUNT_SIG;
128 ("?asp"|"?account_sigpath") /* query signature path */ return QUERY_ACCOUNT_SIGPATH;
129 ("?aT"|"?account_dict") /* query account main dict enabled */ return QUERY_ACCOUNT_DICT;
130 ("?ABc"|"?addrbook_cc") /* query completion for 'Cc' in address book */ return QUERY_CC_FOUND_IN_ADDRESSBOOK;
131 ("?ABf"|"?addrbook_from") /* query completion for 'From' in address book */ return QUERY_FROM_FOUND_IN_ADDRESSBOOK;
132 ("?ABt"|"?addrbook_to") /* query completion for 'To' in address book */ return QUERY_TO_FOUND_IN_ADDRESSBOOK;
133 ("!d"|"!date") /* query not(date) */ return QUERY_NOT_DATE;
134 ("!f"|"!from") /* query not(from) */ return QUERY_NOT_FROM;
135 ("!N"|"!F"|"!L"|"!I"|"!fullname"|"!firstname"|"!lastname"|"!initials") /* query not(from name) */ return QUERY_NOT_FULLNAME;
136 ("!s"|"!subject") /* query not(subject) */ return QUERY_NOT_SUBJECT;
137 ("!t"|"!to") /* query not(to) */ return QUERY_NOT_TO;
138 ("!T"|"!dict") /* query not(current dictionary set and enabled) */ return QUERY_NOT_DICT;
139 ("!c"|"!cc") /* query not(cc) */ return QUERY_NOT_CC;
140 ("!n"|"!newsgroups") /* query not(newsgroups) */ return QUERY_NOT_NEWSGROUPS;
141 ("!i"|"!messageid") /* query not(message-id) */ return QUERY_NOT_MESSAGEID;
142 ("!r"|"!references") /* query not(references) */ return QUERY_NOT_REFERENCES;
143 ("!af"|"!account_fullname") /* query not(full name in compose account) */ return QUERY_NOT_ACCOUNT_FULL_NAME;
144 ("!ao"|"!account_org") /* query not(organization in compose account) */ return QUERY_NOT_ACCOUNT_ORGANIZATION;
145 ("!as"|"!account_sig") /* query not(signature) */ return QUERY_NOT_ACCOUNT_SIG;
146 ("!asp"|"!account_sigpath") /* query not(signature path) */ return QUERY_NOT_ACCOUNT_SIGPATH;
147 ("!aT"|"!account_dict") /* query not(account main dict enabled and set) */ return QUERY_NOT_ACCOUNT_DICT;
148 ("!ABc"|"!addrbook_cc") /* query not(completion for 'Cc' in address book) */ return QUERY_NOT_CC_FOUND_IN_ADDRESSBOOK;
149 ("!ABf"|"!addrbook_from") /* query not(completion for 'From' in address book) */ return QUERY_NOT_FROM_FOUND_IN_ADDRESSBOOK;
150 ("!ABt"|"!addrbook_to") /* query not(completion for 'To' in address book) */ return QUERY_NOT_TO_FOUND_IN_ADDRESSBOOK;
151 ("|f"|"|file") /* insert file */ return INSERT_FILE;
152 ("|p"|"|program") /* insert program output */ return INSERT_PROGRAMOUTPUT;
153 ("|i"|"|input") /* insert user input */ return INSERT_USERINPUT;
154 ("|a"|"|attach") /* attach file */ return ATTACH_FILE;
155 ("|A"|"|attach_program") /*  file whose name's got from program output */ return ATTACH_PROGRAMOUTPUT;
156 <S_DATE>"{" return OPARENT;
157 <S_DATE>"}" { BEGIN S_NORMAL; return CPARENT; }
158 <S_NORMAL>"{" return OPARENT;
159 <S_NORMAL>"}" return CPARENT;
160 . { yylval.chr = yytext[0]; return CHARACTER; }
161
162 %%