2 /************************************************************************
4 * Copyright 2012 Jonatan Liljedahl <lijon@kymatica.com>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 ************************************************************************/
23 #include "SCDoc.tab.hpp"
25 int scdoc_start_token = 0;
27 //#define YY_USER_ACTION { scdoclloc.first_column = colnum; colnum=colnum+yyleng; scdoclloc.last_column=colnum; if(scdoclloc.first_line!=yylineno) colnum=1; scdoclloc.first_line = scdoclloc.last_line = yylineno;}
29 static int method_caller;
33 %option noyywrap never-interactive nounistd yylineno
49 if (scdoc_start_token) {
50 int t = scdoc_start_token;
51 scdoc_start_token = 0;
53 if(t==START_METADATA) BEGIN(eat);
59 (?i:[ \t]*class::[ \t]*) return CLASS;
60 (?i:[ \t]*title::[ \t]*) return TITLE;
61 (?i:[ \t]*summary::[ \t]*) return SUMMARY;
62 (?i:[ \t]*related::[ \t]*) return RELATED;
63 (?i:[ \t]*categories::[ \t]*) return CATEGORIES;
64 (?i:[ \t]*redirect::[ \t]*) return REDIRECT;
66 (?i:[ \t]*classtree::[ \t]*) return CLASSTREE;
67 (?i:[ \t]*keyword::[ \t]*) return KEYWORD;
69 (?i:[ \t]*private::[ \t]*) return PRIVATE;
70 (?i:[ \t]*section::[ \t]*) return SECTION;
71 (?i:[ \t]*subsection::[ \t]*) return SUBSECTION;
72 (?i:[ \t]*copymethod::[ \t]*) return COPYMETHOD;
73 (?i:[ \t]*method::[ \t]*) method_caller = YY_START; BEGIN(method); return METHOD;
74 (?i:[ \t]*argument::[ \t]*) return ARGUMENT;
76 (?i:[ \t]*description::[ \t\n\r]*) return DESCRIPTION;
77 (?i:[ \t]*classmethods::[ \t\n\r]*) return CLASSMETHODS;
78 (?i:[ \t]*instancemethods::[ \t\n\r]*) return INSTANCEMETHODS;
79 (?i:[ \t]*examples::[ \t\n\r]*) return EXAMPLES;
81 (?i:[ \t]*returns::[ \t\n\r]*) return RETURNS;
82 (?i:[ \t]*discussion::[ \t\n\r]*) return DISCUSSION;
84 (?i:[ \t]*list::[ \t\n\r]*) return LIST;
85 (?i:[ \t]*tree::[ \t\n\r]*) return TREE;
86 (?i:[ \t]*numberedlist::[ \t\n\r]*) return NUMBEREDLIST;
87 (?i:[ \t]*definitionlist::[ \t\n\r]*) return DEFINITIONLIST;
88 (?i:[ \t]*table::[ \t\n\r]*) return TABLE;
89 (?i:[ \t]*footnote::[ \t\n\r]*) return FOOTNOTE;
90 (?i:[ \t]*warning::[ \t\n\r]*) return WARNING;
91 (?i:[ \t]*note::[ \t\n\r]*) return NOTE;
93 (?i:link::[ \t]*) BEGIN(verbatim); return LINK;
94 (?i:anchor::[ \t]*) BEGIN(verbatim); return ANCHOR;
95 (?i:image::[ \t]*) BEGIN(verbatim); return IMAGE;
96 (?i:soft::[ \t\n\r]*) BEGIN(verbatim); return SOFT;
97 (?i:strong::[ \t\n\r]*) BEGIN(verbatim); return STRONG;
98 (?i:emphasis::[ \t\n\r]*) BEGIN(verbatim); return EMPHASIS;
99 (?i:code::[ \t]*) BEGIN(verbatim); return CODE;
100 (?i:teletype::[ \t]*) BEGIN(verbatim); return TELETYPE;
101 (?i:math::[ \t]*) BEGIN(verbatim); return MATH;
103 (?i:[ \t]*code::[ \t]*\n+) BEGIN(verbatim2); return CODEBLOCK;
104 (?i:[ \t]*teletype::[ \t]*\n+) BEGIN(verbatim2); return TELETYPEBLOCK;
105 (?i:[ \t]*math::[ \t]*\n+) BEGIN(verbatim2); return MATHBLOCK;
107 <INITIAL,verbatim>[ \t\n\r]*:: BEGIN(0); return TAGSYM;
108 <verbatim2>\n[ \t\n\r]*:: BEGIN(0); return TAGSYM;
109 <verbatim2>\n[ \t]*\\:: scdoclval.str = strdup("\n::"); return TEXT;
110 [ \t]*\|\|[ \t\n\r]* return BARS;
111 [ \t]*\#\#[ \t\n\r]* return HASHES;
113 <verbatim2>\n scdoclval.str = strdup("\n"); return TEXT;
114 <verbatim>\n+ scdoclval.str = strdup(" "); return TEXT;
116 \n([ \t\r]*\n)+ return EMPTYLINES;
118 <INITIAL,method>[ \t]*,[ \t]* scdoclval.str = strdup(scdoctext); return COMMA;
120 \\\|\| scdoclval.str = strdup("||"); return TEXT;
121 \\\#\# scdoclval.str = strdup("##"); return TEXT;
122 <INITIAL,verbatim>\\:: scdoclval.str = strdup("::"); return TEXT;
123 <verbatim,verbatim2>\t scdoclval.str = strdup(" "); return TEXT;
124 [ \t]+ scdoclval.str = strdup(" "); return TEXT;
128 [a-zA-Z]+:\/\/[^ \t\n\r:,]+ scdoclval.str = strdup(scdoctext); return URL;
129 <method>[a-z][a-zA-Z0-9_]*|[-<>@|&%*+/!?=]+ scdoclval.str = strdup(scdoctext); return METHODNAME;
130 <method>\([^()]+\) scdoclval.str = strdup(scdoctext); return METHODARGS;
131 <method>[ \r\t]+ /* eat this */
132 <method>\n BEGIN(method_caller); return NEWLINE;
133 <method>. return BAD_METHODNAME;
136 <INITIAL,verbatim,verbatim2>[.!?(){}\[\]'"0-9]+ |
137 <verbatim,verbatim2>[^:\\\t\n\r ]+ |
139 <INITIAL,verbatim,verbatim2>. scdoclval.str = strdup(scdoctext); return TEXT;
141 <metadata,eat>(?i:[ \t]*class::[ \t]*) BEGIN(metadata); return CLASS;
142 <metadata,eat>(?i:[ \t]*title::[ \t]*) BEGIN(metadata); return TITLE;
143 <metadata,eat>(?i:[ \t]*summary::[ \t]*) BEGIN(metadata); return SUMMARY;
144 <metadata,eat>(?i:[ \t]*related::[ \t]*) BEGIN(metadata); return RELATED;
145 <metadata,eat>(?i:[ \t]*categories::[ \t]*) BEGIN(metadata); return CATEGORIES;
146 <metadata,eat>(?i:[ \t]*redirect::[ \t]*) BEGIN(metadata); return REDIRECT;
147 <metadata,eat>(?i:[ \t]*classtree::[ \t]*) BEGIN(metadata); return CLASSTREE;
148 <metadata,eat>(?i:[ \t]*keyword::[ \t]*) BEGIN(metadata); return KEYWORD;
149 <metadata,eat>(?i:[ \t]*private::[ \t]*) BEGIN(metadata); return PRIVATE;
150 <metadata,eat>(?i:[ \t]*section::[ \t]*) BEGIN(metadata); return SECTION;
151 <metadata,eat>(?i:[ \t]*subsection::[ \t]*) BEGIN(metadata); return SUBSECTION;
152 <metadata,eat>(?i:[ \t]*copymethod::[ \t]*) BEGIN(metadata); return COPYMETHOD;
153 <metadata,eat>(?i:[ \t]*method::[ \t]*) method_caller = YY_START; BEGIN(method); return METHOD;
154 <metadata,eat>(?i:[ \t]*description::[ \t\n\r]*) BEGIN(eat); return DESCRIPTION;
155 <metadata,eat>(?i:[ \t]*classmethods::[ \t\n\r]*) BEGIN(eat); return CLASSMETHODS;
156 <metadata,eat>(?i:[ \t]*instancemethods::[ \t\n\r]*) BEGIN(eat); return INSTANCEMETHODS;
157 <metadata,eat>(?i:[ \t]*examples::[ \t\n\r]*) BEGIN(eat); return EXAMPLES;
158 <metadata>\n BEGIN(eat); return NEWLINE;
159 <metadata>[ \t]*,[ \t]* scdoclval.str = strdup(scdoctext); return COMMA;
160 <metadata>[a-zA-Z]+ |
162 <metadata>[^:\\\n\r,]+ |
163 <metadata>. scdoclval.str = strdup(scdoctext); return TEXT;
164 <metadata>\\:: scdoclval.str = strdup("::"); return TEXT;
165 <eat>(?i:link::[ \t]*) BEGIN(eat2);
166 <eat>(?i:anchor::[ \t]*) BEGIN(eat2);
167 <eat>(?i:image::[ \t]*) BEGIN(eat2);
168 <eat>(?i:soft::[ \t\n\r]*) BEGIN(eat2);
169 <eat>(?i:strong::[ \t\n\r]*) BEGIN(eat2);
170 <eat>(?i:emphasis::[ \t\n\r]*) BEGIN(eat2);
171 <eat>(?i:code::[ \t]*) BEGIN(eat2);
172 <eat>(?i:teletype::[ \t]*) BEGIN(eat2);
173 <eat>(?i:math::[ \t]*) BEGIN(eat2);
174 <eat>(?i:[ \t]*code::[ \t]*\n+) BEGIN(eat3);
175 <eat>(?i:[ \t]*teletype::[ \t]*\n+) BEGIN(eat3);
176 <eat>(?i:[ \t]*math::[ \t]*\n+) BEGIN(eat3);
177 <eat2>[ \t\n\r]*:: BEGIN(eat);
178 <eat3>\n[ \t\n\r]*:: BEGIN(eat);
179 <eat,eat2,eat3>.|\n /* empty */