2007-08-12 [ticho] 2.10.0cvs114
[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 %}
40
41 %%
42
43 %{
44 /*
45  * NOTES:
46  * this lex script used to use characters also in use
47  * by strftime() (which we want to use for custom
48  * time formats in replies and templates). to circumvent
49  * this we have to play a little bit with states.
50  *
51  * these are the characters we also want to use in the
52  * %D time customizer:
53  *
54  * %a %A %b %B %c %C %d %H %I %j %m %M %p %S %w %x %y %Y %Z
55  *
56  * you can use these characters too, but don't forget to
57  * prepend them with the <S_NORMAL> state.
58  *
59  * also there is also work around for resetting the state
60  * (firsttime variable). this assumes that yylex() will
61  * always return to S_NORMAL after quote fmt parsing is
62  * done.
63  */
64 %} 
65
66 %{
67         if (quote_fmt_firsttime) {
68                 BEGIN S_NORMAL;
69                 quote_fmt_firsttime = 0;
70         }       
71 %}
72
73 <S_NORMAL>("%X"|"%cursor") /* cursor pos */ return SET_CURSOR_POS;
74 <S_NORMAL>("%A"|"%email") /* email address */ return SHOW_MAIL_ADDRESS;
75 <S_NORMAL>("%c"|"%cc") /* cc */ return SHOW_CC;
76 <S_NORMAL>("%d"|"%date") /* date */ return SHOW_DATE;
77 <S_NORMAL>("%D"|"%date_fmt") /* date */ { BEGIN S_DATE; return SHOW_DATE_EXPR; }
78 <S_NORMAL>("%f"|"%from") /* from */ return SHOW_FROM;
79 <S_NORMAL>("%F"|"%firstname") /* first name */ return SHOW_FIRST_NAME;
80 <S_NORMAL>("%i"|"%messageid") /* message-id */ return SHOW_MESSAGEID;
81 <S_NORMAL>("%I"|"%initials") /* initial of sender */ return SHOW_SENDER_INITIAL;
82 <S_NORMAL>("%m"|"%msg_no_sig") /* message with no signature */ return SHOW_MESSAGE_NO_SIGNATURE;
83 <S_NORMAL>("%M"|"%msg") /* message */ return SHOW_MESSAGE;
84 <S_NORMAL>("%n"|"%newsgroups") /* newsgroups */ return SHOW_NEWSGROUPS;
85 <S_NORMAL>("%N"|"%fullname") /* full name */ return SHOW_FULLNAME;
86 <S_NORMAL>("%L"|"%lastname") /* last name */ return SHOW_LAST_NAME;
87 <S_NORMAL>("%r"|"%references") /* references */ return SHOW_REFERENCES;
88 <S_NORMAL>("%s"|"%subject") /* subject */ return SHOW_SUBJECT;
89 <S_NORMAL>("%t"|"%to") /* to */ return SHOW_TO;
90 <S_NORMAL>("%T"|"%dict") /* current dictionary */ return SHOW_DICT;
91 <S_NORMAL>("%tags") /* tags */ return SHOW_TAGS;
92 <S_NORMAL>("%Q"|"%quoted_msg") /* quoted message */ return SHOW_QUOTED_MESSAGE;
93 <S_NORMAL>("%q"|"%quoted_msg_no_sig") /* quoted message with no signature */ return SHOW_QUOTED_MESSAGE_NO_SIGNATURE;
94 <S_NORMAL>("%af"|"%account_fullname") /* full name in compose account */ return SHOW_ACCOUNT_FULL_NAME;
95 <S_NORMAL>("%am"|"%account_email") /* mail address in compose account */ return SHOW_ACCOUNT_MAIL_ADDRESS;
96 <S_NORMAL>("%an"|"%account_name") /* compose account name itself */ return SHOW_ACCOUNT_NAME;
97 <S_NORMAL>("%ao"|"%account_org") /* organization in compose account */ return SHOW_ACCOUNT_ORGANIZATION;
98 <S_NORMAL>("%aT"|"%account_dict") /* main dict (if enabled) in compose account */ return SHOW_ACCOUNT_DICT;
99 <S_NORMAL>("%ABc"|"%addrbook_cc") /* completion of 'Cc' from the address book */ return SHOW_ADDRESSBOOK_COMPLETION_FOR_CC;
100 <S_NORMAL>("%ABf"|"%addrbook_from") /* completion of 'From' from the address book */ return SHOW_ADDRESSBOOK_COMPLETION_FOR_FROM;
101 <S_NORMAL>("%ABt"|"%addrbook_to") /* completion of 'To' from the address book */ return SHOW_ADDRESSBOOK_COMPLETION_FOR_TO;
102 "\\\%" /* % */ return SHOW_PERCENT;
103 "\\\\" /* \ */ return SHOW_BACKSLASH;
104 "\\t"|"\t" /* tab */ return SHOW_TAB;
105 "\\n"|"\n" /* return */ { if (yytext[0] == '\n') line++; return SHOW_EOL; }
106 "\\?" /* ? */ return SHOW_QUESTION_MARK;
107 "\\!" return SHOW_EXCLAMATION_MARK;
108 "\\|" return SHOW_PIPE;
109 "\\{" return SHOW_OPARENT;
110 "\\}" return SHOW_CPARENT;
111 ("?d"|"?date") /* query date */ return QUERY_DATE;
112 ("?f"|"?from") /* query from */ return QUERY_FROM;
113 ("?N"|"?F"|"?L"|"?I"|"?fullname"|"?firstname"|"?lastname"|"?initials") /* query from name */ return QUERY_FULLNAME;
114 ("?s"|"?subject") /* query subject */ return QUERY_SUBJECT;
115 ("?t"|"?to") /* query to */ return QUERY_TO;
116 ("?T"|"?dict") /* query current dictionary set and enabled */ return QUERY_DICT;
117 ("?c"|"?cc") /* query cc */ return QUERY_CC;
118 ("?n"|"?newsgroups") /* query newsgroups */ return QUERY_NEWSGROUPS;
119 ("?i"|"?messageid") /* query message-id */ return QUERY_MESSAGEID;
120 ("?r"|"?references") /* query references */ return QUERY_REFERENCES;
121 ("?af"|"?account_fullname") /* query full name in compose account */ return QUERY_ACCOUNT_FULL_NAME;
122 ("?ao"|"?account_org") /* query organization in compose account */ return QUERY_ACCOUNT_ORGANIZATION;
123 ("?aT"|"?account_dict") /* query account main dict enabled */ return QUERY_ACCOUNT_DICT;
124 ("?ABc"|"?addrbook_cc") /* query completion for 'Cc' in address book */ return QUERY_CC_FOUND_IN_ADDRESSBOOK;
125 ("?ABf"|"?addrbook_from") /* query completion for 'From' in address book */ return QUERY_FROM_FOUND_IN_ADDRESSBOOK;
126 ("?ABt"|"?addrbook_to") /* query completion for 'To' in address book */ return QUERY_TO_FOUND_IN_ADDRESSBOOK;
127 ("!d"|"!date") /* query not(date) */ return QUERY_NOT_DATE;
128 ("!f"|"!from") /* query not(from) */ return QUERY_NOT_FROM;
129 ("!N"|"!F"|"!L"|"!I"|"!fullname"|"!firstname"|"!lastname"|"!initials") /* query not(from name) */ return QUERY_NOT_FULLNAME;
130 ("!s"|"!subject") /* query not(subject) */ return QUERY_NOT_SUBJECT;
131 ("!t"|"!to") /* query not(to) */ return QUERY_NOT_TO;
132 ("!T"|"!dict") /* query not(current dictionary set and enabled) */ return QUERY_NOT_DICT;
133 ("!c"|"!cc") /* query not(cc) */ return QUERY_NOT_CC;
134 ("!n"|"!newsgroups") /* query not(newsgroups) */ return QUERY_NOT_NEWSGROUPS;
135 ("!i"|"!messageid") /* query not(message-id) */ return QUERY_NOT_MESSAGEID;
136 ("!r"|"!references") /* query not(references) */ return QUERY_NOT_REFERENCES;
137 ("!af"|"!account_fullname") /* query not(full name in compose account) */ return QUERY_NOT_ACCOUNT_FULL_NAME;
138 ("!ao"|"!account_org") /* query not(organization in compose account) */ return QUERY_NOT_ACCOUNT_ORGANIZATION;
139 ("!aT"|"!account_dict") /* query not(account main dict enabled and set) */ return QUERY_NOT_ACCOUNT_DICT;
140 ("!ABc"|"!addrbook_cc") /* query not(completion for 'Cc' in address book) */ return QUERY_NOT_CC_FOUND_IN_ADDRESSBOOK;
141 ("!ABf"|"!addrbook_from") /* query not(completion for 'From' in address book) */ return QUERY_NOT_FROM_FOUND_IN_ADDRESSBOOK;
142 ("!ABt"|"!addrbook_to") /* query not(completion for 'To' in address book) */ return QUERY_NOT_TO_FOUND_IN_ADDRESSBOOK;
143 ("|f"|"|file") /* insert file */ return INSERT_FILE;
144 ("|p"|"|program") /* insert program output */ return INSERT_PROGRAMOUTPUT;
145 ("|i"|"|input") /* insert user input */ return INSERT_USERINPUT;
146 <S_DATE>"{" return OPARENT;
147 <S_DATE>"}" { BEGIN S_NORMAL; return CPARENT; }
148 <S_NORMAL>"{" return OPARENT;
149 <S_NORMAL>"}" return CPARENT;
150 . { yylval.chr = yytext[0]; return CHARACTER; }
151
152 %%