4022c06b85968acc53e677b801e7367e479f5355
[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 2 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, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
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 %}
39
40 %%
41
42 %{
43 /*
44  * NOTES:
45  * this lex script used to use characters also in use
46  * by strftime() (which we want to use for custom
47  * time formats in replies and templates). to circumvent
48  * this we have to play a little bit with states.
49  *
50  * these are the characters we also want to use in the
51  * %D time customizer:
52  *
53  * %a %A %b %B %c %C %d %H %I %j %m %M %p %S %w %x %y %Y %Z
54  *
55  * you can use these characters too, but don't forget to
56  * prepend them with the <S_NORMAL> state.
57  *
58  * also there is also work around for resetting the state
59  * (firsttime variable). this assumes that yylex() will
60  * always return to S_NORMAL after quote fmt parsing is
61  * done.
62  */
63 %} 
64
65 %{
66         if (quote_fmt_firsttime) {
67                 BEGIN S_NORMAL;
68                 quote_fmt_firsttime = 0;
69         }       
70 %}
71
72 <S_NORMAL>"%X" /* cursor pos */ return SET_CURSOR_POS;
73 <S_NORMAL>"%A" /* email address */ return SHOW_MAIL_ADDRESS;
74 <S_NORMAL>"%c" /* cc */ return SHOW_CC;
75 <S_NORMAL>"%d" /* date */ return SHOW_DATE;
76 <S_NORMAL>"%D" /* date */ { BEGIN S_DATE; return SHOW_DATE_EXPR; }
77 <S_NORMAL>"%f" /* from */ return SHOW_FROM;
78 <S_NORMAL>"%F" /* first name */ return SHOW_FIRST_NAME;
79 <S_NORMAL>"%i" /* message-id */ return SHOW_MESSAGEID;
80 <S_NORMAL>"%I" /* initial of sender */ return SHOW_SENDER_INITIAL;
81 <S_NORMAL>"%m" /* message with no signature */ return SHOW_MESSAGE_NO_SIGNATURE;
82 <S_NORMAL>"%M" /* message */ return SHOW_MESSAGE;
83 <S_NORMAL>"%n" /* newsgroups */ return SHOW_NEWSGROUPS;
84 <S_NORMAL>"%N" /* full name */ return SHOW_FULLNAME;
85 <S_NORMAL>"%L" /* last name */ return SHOW_LAST_NAME;
86 <S_NORMAL>"%r" /* references */ return SHOW_REFERENCES;
87 <S_NORMAL>"%s" /* subject */ return SHOW_SUBJECT;
88 <S_NORMAL>"%t" /* to */ return SHOW_TO;
89 <S_NORMAL>"%Q" /* quoted message */ return SHOW_QUOTED_MESSAGE;
90 <S_NORMAL>"%q" /* quoted message with no signature */ return SHOW_QUOTED_MESSAGE_NO_SIGNATURE;
91 <S_NORMAL>"%af" /* full name in compose account */ return SHOW_ACCOUNT_FULL_NAME;
92 <S_NORMAL>"%am" /* mail address in compose account */ return SHOW_ACCOUNT_MAIL_ADDRESS;
93 <S_NORMAL>"%an" /* compose account name itself */ return SHOW_ACCOUNT_NAME;
94 <S_NORMAL>"%ao" /* organization in compose account */ return SHOW_ACCOUNT_ORGANIZATION;
95 "\\\%" /* % */ return SHOW_PERCENT;
96 "\\\\" /* \ */ return SHOW_BACKSLASH;
97 "\\t"|"\t" /* tab */ return SHOW_TAB;
98 "\\n"|"\n" /* return */ return SHOW_EOL;
99 "\\?" /* ? */ return SHOW_QUESTION_MARK;
100 "\\!" return SHOW_EXCLAMATION_MARK;
101 "\\|" return SHOW_PIPE;
102 "\\{" return SHOW_OPARENT;
103 "\\}" return SHOW_CPARENT;
104 "?d" /* query date */ return QUERY_DATE;
105 "?f" /* query from */ return QUERY_FROM;
106 "?N"|"?F"|"?L"|"?I" /* query from name */ return QUERY_FULLNAME;
107 "?s" /* query subject */ return QUERY_SUBJECT;
108 "?t" /* query to */ return QUERY_TO;
109 "?c" /* query cc */ return QUERY_CC;
110 "?n" /* query newsgroups */ return QUERY_NEWSGROUPS;
111 "?i" /* query message-id */ return QUERY_MESSAGEID;
112 "?r" /* query references */ return QUERY_REFERENCES;
113 "?af" /* query full name in compose account */ return QUERY_ACCOUNT_FULL_NAME;
114 "?ao" /* query organization in compose account */ return QUERY_ACCOUNT_ORGANIZATION;
115 "|f" /* insert file */ return INSERT_FILE;
116 "|p" /* insert program output */ return INSERT_PROGRAMOUTPUT;
117 "|i" /* insert user input */ return INSERT_USERINPUT;
118 "!d" /* query date */ return QUERY_NOT_DATE;
119 "!f" /* query from */ return QUERY_NOT_FROM;
120 "!N"|"!F"|"!L"|"!I" /* query not(from name) */ return QUERY_NOT_FULLNAME;
121 "!s" /* query not(subject) */ return QUERY_NOT_SUBJECT;
122 "!t" /* query not(to) */ return QUERY_NOT_TO;
123 "!c" /* query not(cc) */ return QUERY_NOT_CC;
124 "!n" /* query not(newsgroups) */ return QUERY_NOT_NEWSGROUPS;
125 "!i" /* query not(message-id) */ return QUERY_NOT_MESSAGEID;
126 "!r" /* query not(references) */ return QUERY_NOT_REFERENCES;
127 "!af" /* query not(full name in compose account) */ return QUERY_NOT_ACCOUNT_FULL_NAME;
128 "!ao" /* query not(organization in compose account) */ return QUERY_NOT_ACCOUNT_ORGANIZATION;
129 <S_DATE>"{" return OPARENT;
130 <S_DATE>"}" { BEGIN S_NORMAL; return CPARENT; }
131 <S_NORMAL>"{" return OPARENT;
132 <S_NORMAL>"}" return CPARENT;
133 . { yylval.chr = yytext[0]; return CHARACTER; }
134
135 %%