blob: 76acda1344438ef0f3fb6a51c58633a1b0eaf5eb [file] [log] [blame]
David Reissea2cba82009-03-30 21:35:00 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
Mark Sleee9ce01c2007-05-16 02:29:53 +00009 *
David Reissea2cba82009-03-30 21:35:00 +000010 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
Mark Sleee9ce01c2007-05-16 02:29:53 +000018 */
19
20/**
Mark Slee31985722006-05-24 21:45:31 +000021 * Thrift scanner.
Mark Slee27ed6ec2007-08-16 01:26:31 +000022 *
Mark Slee31985722006-05-24 21:45:31 +000023 * Tokenizes a thrift definition file.
Mark Slee31985722006-05-24 21:45:31 +000024 */
Mark Sleef5377b32006-10-10 01:42:59 +000025
Mark Slee31985722006-05-24 21:45:31 +000026%{
27
Christian Lavoieaf65f1b2010-11-24 21:58:05 +000028/* This is redundant with some of the flags in Makefile.am, but it works
29 * when people override CXXFLAGS without being careful. The pragmas are
30 * the 'right' way to do it, but don't work on old-enough GCC (in particular
31 * the GCC that ship on Mac OS X 10.6.5, *counter* to what the GNU docs say)
32 *
33 * We should revert the Makefile.am changes once Apple ships a reasonable
34 * GCC.
35 */
Ben Craige9576752013-10-11 08:19:16 -050036#ifdef __GNUC__
Roger Meier3b771a12010-11-17 22:11:26 +000037#pragma GCC diagnostic ignored "-Wunused-function"
38#pragma GCC diagnostic ignored "-Wunused-label"
Ben Craige9576752013-10-11 08:19:16 -050039#endif
40
41#ifdef _MSC_VER
42//warning C4102: 'find_rule' : unreferenced label
43#pragma warning(disable:4102)
44//avoid isatty redefinition
45#define YY_NEVER_INTERACTIVE 1
Roger Meier86fded22015-05-15 12:01:38 +020046
47#define YY_NO_UNISTD_H 1
Ben Craige9576752013-10-11 08:19:16 -050048#endif
Roger Meier3b771a12010-11-17 22:11:26 +000049
Jens Geyer8cd3efe2013-09-16 22:17:52 +020050#include <cassert>
David Reiss82e6fc02009-03-26 23:32:36 +000051#include <string>
David Reissf1454162008-06-30 20:45:47 +000052#include <errno.h>
Roger Meier9212e792012-06-12 21:01:06 +000053#include <stdlib.h>
David Reissf1454162008-06-30 20:45:47 +000054
Ben Craige9576752013-10-11 08:19:16 -050055#ifdef _MSC_VER
56#include "windows/config.h"
Roger Meier57e6de42014-07-16 10:19:59 +020057#endif
Mark Slee31985722006-05-24 21:45:31 +000058#include "main.h"
David Reisscbd4bac2007-08-14 17:12:33 +000059#include "globals.h"
Mark Slee31985722006-05-24 21:45:31 +000060#include "parse/t_program.h"
61
Mark Sleef5377b32006-10-10 01:42:59 +000062/**
63 * Must be included AFTER parse/t_program.h, but I can't remember why anymore
64 * because I wrote this a while ago.
65 */
jfarrell4f54d132014-07-10 09:23:43 -040066#if defined(BISON_USE_PARSER_H_EXTENSION)
jfarrell92f24b22013-08-17 15:47:13 -040067#include "thrifty.h"
jfarrell4f54d132014-07-10 09:23:43 -040068#else
69#include "thrifty.hh"
70#endif
Mark Slee31985722006-05-24 21:45:31 +000071
Mark Sleef12865a2007-01-12 00:23:26 +000072void thrift_reserved_keyword(char* keyword) {
73 yyerror("Cannot use reserved language keyword: \"%s\"\n", keyword);
74 exit(1);
75}
76
David Reissf1454162008-06-30 20:45:47 +000077void integer_overflow(char* text) {
78 yyerror("This integer is too big: \"%s\"\n", text);
79 exit(1);
80}
81
Bryan Duxbury235f8b52011-08-19 18:27:47 +000082void unexpected_token(char* text) {
83 yyerror("Unexpected token in input: \"%s\"\n", text);
84 exit(1);
85}
86
Mark Slee31985722006-05-24 21:45:31 +000087%}
88
Mark Sleef5377b32006-10-10 01:42:59 +000089/**
90 * Provides the yylineno global, useful for debugging output
91 */
Mark Slee27ed6ec2007-08-16 01:26:31 +000092%option lex-compat
Mark Slee31985722006-05-24 21:45:31 +000093
Mark Slee27ed6ec2007-08-16 01:26:31 +000094/**
David Reiss4563acd2010-08-31 16:51:29 +000095 * Our inputs are all single files, so no need for yywrap
96 */
97%option noyywrap
98
99/**
Christian Lavoie77215d82010-11-07 19:42:48 +0000100 * We don't use it, and it fires up warnings at -Wall
101 */
102%option nounput
103
104/**
Mark Sleef5377b32006-10-10 01:42:59 +0000105 * Helper definitions, comments, constants, and whatnot
106 */
107
Mark Sleebd588222007-11-21 08:43:35 +0000108intconstant ([+-]?[0-9]+)
Jens Geyer5ec21212015-04-26 15:24:59 +0200109hexconstant ([+-]?"0x"[0-9A-Fa-f]+)
Mark Sleebd588222007-11-21 08:43:35 +0000110dubconstant ([+-]?[0-9]*(\.[0-9]+)?([eE][+-]?[0-9]+)?)
Carl Yeksigiande074082013-06-04 04:28:31 -0400111identifier ([a-zA-Z_](\.[a-zA-Z_0-9]|[a-zA-Z_0-9])*)
Mark Sleebd588222007-11-21 08:43:35 +0000112whitespace ([ \t\r\n]*)
113sillycomm ("/*""*"*"*/")
114multicomm ("/*"[^*]"/"*([^*/]|[^*]"/"|"*"[^/])*"*"*"*/")
115doctext ("/**"([^*/]|[^*]"/"|"*"[^/])*"*"*"*/")
116comment ("//"[^\n]*)
117unixcomment ("#"[^\n]*)
118symbol ([:;\,\{\}\(\)\=<>\[\]])
Carl Yeksigiande074082013-06-04 04:28:31 -0400119st_identifier ([a-zA-Z-](\.[a-zA-Z_0-9-]|[a-zA-Z_0-9-])*)
David Reiss82e6fc02009-03-26 23:32:36 +0000120literal_begin (['\"])
Mark Slee31985722006-05-24 21:45:31 +0000121
122%%
123
Mark Sleebd588222007-11-21 08:43:35 +0000124{whitespace} { /* do nothing */ }
125{sillycomm} { /* do nothing */ }
126{multicomm} { /* do nothing */ }
127{comment} { /* do nothing */ }
128{unixcomment} { /* do nothing */ }
Mark Slee31985722006-05-24 21:45:31 +0000129
Mark Sleebd588222007-11-21 08:43:35 +0000130{symbol} { return yytext[0]; }
Roger Meier0c3c8952011-08-22 21:38:16 +0000131"*" { return yytext[0]; }
Mark Slee9cb7c612006-09-01 22:17:45 +0000132
Bryan Duxbury6c928f32011-10-13 21:32:52 +0000133"false" { yylval.iconst=0; return tok_int_constant; }
134"true" { yylval.iconst=1; return tok_int_constant; }
135
Mark Sleebd588222007-11-21 08:43:35 +0000136"namespace" { return tok_namespace; }
Jens Geyer73880372015-11-14 15:21:57 +0100137"cpp_namespace" { error_unsupported_namespace_decl("cpp"); /* do nothing */ }
Mark Sleebd588222007-11-21 08:43:35 +0000138"cpp_include" { return tok_cpp_include; }
139"cpp_type" { return tok_cpp_type; }
Jens Geyer73880372015-11-14 15:21:57 +0100140"java_package" { error_unsupported_namespace_decl("java_package", "java"); /* do nothing */ }
141"cocoa_prefix" { error_unsupported_namespace_decl("cocoa_prefix", "cocoa"); /* do nothing */ }
142"csharp_namespace" { error_unsupported_namespace_decl("csharp"); /* do nothing */ }
143"delphi_namespace" { error_unsupported_namespace_decl("delphi"); /* do nothing */ }
144"php_namespace" { error_unsupported_namespace_decl("php"); /* do nothing */ }
145"py_module" { error_unsupported_namespace_decl("py_module", "py"); /* do nothing */ }
146"perl_package" { error_unsupported_namespace_decl("perl_package", "perl"); /* do nothing */ }
147"ruby_namespace" { error_unsupported_namespace_decl("ruby"); /* do nothing */ }
148"smalltalk_category" { error_unsupported_namespace_decl("smalltalk_category", "smalltalk.category"); /* do nothing */ }
149"smalltalk_prefix" { error_unsupported_namespace_decl("smalltalk_category", "smalltalk.category"); /* do nothing */ }
Mark Sleebd588222007-11-21 08:43:35 +0000150"xsd_all" { return tok_xsd_all; }
151"xsd_optional" { return tok_xsd_optional; }
152"xsd_nillable" { return tok_xsd_nillable; }
Jens Geyer73880372015-11-14 15:21:57 +0100153"xsd_namespace" { error_unsupported_namespace_decl("xsd"); /* do nothing */ }
Mark Sleebd588222007-11-21 08:43:35 +0000154"xsd_attrs" { return tok_xsd_attrs; }
155"include" { return tok_include; }
156"void" { return tok_void; }
157"bool" { return tok_bool; }
Jens Geyer40c28d32015-10-20 23:13:02 +0200158"byte" {
159 emit_byte_type_warning();
160 return tok_i8;
161}
162"i8" { return tok_i8; }
Mark Sleebd588222007-11-21 08:43:35 +0000163"i16" { return tok_i16; }
164"i32" { return tok_i32; }
165"i64" { return tok_i64; }
166"double" { return tok_double; }
167"string" { return tok_string; }
168"binary" { return tok_binary; }
Jens Geyer0ca234f2013-06-04 22:01:47 +0200169"slist" {
170 pwarning(0, "\"slist\" is deprecated and will be removed in a future compiler version. This type should be replaced with \"string\".\n");
171 return tok_slist;
172}
Carl Yeksigianc3178522013-06-07 12:31:13 -0400173"senum" {
174 pwarning(0, "\"senum\" is deprecated and will be removed in a future compiler version. This type should be replaced with \"string\".\n");
175 return tok_senum;
176}
Mark Sleebd588222007-11-21 08:43:35 +0000177"map" { return tok_map; }
178"list" { return tok_list; }
179"set" { return tok_set; }
David Reisscecbed82009-03-24 20:02:22 +0000180"oneway" { return tok_oneway; }
Mark Sleebd588222007-11-21 08:43:35 +0000181"typedef" { return tok_typedef; }
182"struct" { return tok_struct; }
Bryan Duxburyab3666e2009-09-01 23:03:47 +0000183"union" { return tok_union; }
Mark Sleebd588222007-11-21 08:43:35 +0000184"exception" { return tok_xception; }
185"extends" { return tok_extends; }
186"throws" { return tok_throws; }
187"service" { return tok_service; }
188"enum" { return tok_enum; }
189"const" { return tok_const; }
190"required" { return tok_required; }
191"optional" { return tok_optional; }
David Reisscecbed82009-03-24 20:02:22 +0000192"async" {
193 pwarning(0, "\"async\" is deprecated. It is called \"oneway\" now.\n");
194 return tok_oneway;
195}
Jens Geyer885c6792014-05-02 21:31:55 +0200196"&" { return tok_reference; }
Mark Sleef0712dc2006-10-25 19:03:57 +0000197
Mark Slee52f643d2006-08-09 00:03:43 +0000198
Bryan Duxbury7f3285e2010-08-05 23:28:14 +0000199"BEGIN" { thrift_reserved_keyword(yytext); }
200"END" { thrift_reserved_keyword(yytext); }
201"__CLASS__" { thrift_reserved_keyword(yytext); }
202"__DIR__" { thrift_reserved_keyword(yytext); }
203"__FILE__" { thrift_reserved_keyword(yytext); }
204"__FUNCTION__" { thrift_reserved_keyword(yytext); }
205"__LINE__" { thrift_reserved_keyword(yytext); }
206"__METHOD__" { thrift_reserved_keyword(yytext); }
207"__NAMESPACE__" { thrift_reserved_keyword(yytext); }
Mark Sleebd588222007-11-21 08:43:35 +0000208"abstract" { thrift_reserved_keyword(yytext); }
Bryan Duxbury7f3285e2010-08-05 23:28:14 +0000209"alias" { thrift_reserved_keyword(yytext); }
Mark Sleebd588222007-11-21 08:43:35 +0000210"and" { thrift_reserved_keyword(yytext); }
Mark Sleec27fc312007-12-21 23:52:19 +0000211"args" { thrift_reserved_keyword(yytext); }
Mark Sleebd588222007-11-21 08:43:35 +0000212"as" { thrift_reserved_keyword(yytext); }
213"assert" { thrift_reserved_keyword(yytext); }
Bryan Duxbury7f3285e2010-08-05 23:28:14 +0000214"begin" { thrift_reserved_keyword(yytext); }
Mark Sleebd588222007-11-21 08:43:35 +0000215"break" { thrift_reserved_keyword(yytext); }
216"case" { thrift_reserved_keyword(yytext); }
Bryan Duxbury7f3285e2010-08-05 23:28:14 +0000217"catch" { thrift_reserved_keyword(yytext); }
Mark Sleebd588222007-11-21 08:43:35 +0000218"class" { thrift_reserved_keyword(yytext); }
Bryan Duxbury7f3285e2010-08-05 23:28:14 +0000219"clone" { thrift_reserved_keyword(yytext); }
Mark Sleebd588222007-11-21 08:43:35 +0000220"continue" { thrift_reserved_keyword(yytext); }
221"declare" { thrift_reserved_keyword(yytext); }
222"def" { thrift_reserved_keyword(yytext); }
223"default" { thrift_reserved_keyword(yytext); }
224"del" { thrift_reserved_keyword(yytext); }
225"delete" { thrift_reserved_keyword(yytext); }
226"do" { thrift_reserved_keyword(yytext); }
Bryan Duxbury7f3285e2010-08-05 23:28:14 +0000227"dynamic" { thrift_reserved_keyword(yytext); }
Mark Sleebd588222007-11-21 08:43:35 +0000228"elif" { thrift_reserved_keyword(yytext); }
229"else" { thrift_reserved_keyword(yytext); }
230"elseif" { thrift_reserved_keyword(yytext); }
Bryan Duxbury7f3285e2010-08-05 23:28:14 +0000231"elsif" { thrift_reserved_keyword(yytext); }
232"end" { thrift_reserved_keyword(yytext); }
233"enddeclare" { thrift_reserved_keyword(yytext); }
234"endfor" { thrift_reserved_keyword(yytext); }
235"endforeach" { thrift_reserved_keyword(yytext); }
236"endif" { thrift_reserved_keyword(yytext); }
237"endswitch" { thrift_reserved_keyword(yytext); }
238"endwhile" { thrift_reserved_keyword(yytext); }
239"ensure" { thrift_reserved_keyword(yytext); }
Mark Sleebd588222007-11-21 08:43:35 +0000240"except" { thrift_reserved_keyword(yytext); }
241"exec" { thrift_reserved_keyword(yytext); }
Mark Sleebd588222007-11-21 08:43:35 +0000242"finally" { thrift_reserved_keyword(yytext); }
243"float" { thrift_reserved_keyword(yytext); }
244"for" { thrift_reserved_keyword(yytext); }
245"foreach" { thrift_reserved_keyword(yytext); }
jfarrella1ae93f2015-09-24 22:57:33 -0400246"from" { thrift_reserved_keyword(yytext); }
Mark Sleebd588222007-11-21 08:43:35 +0000247"function" { thrift_reserved_keyword(yytext); }
248"global" { thrift_reserved_keyword(yytext); }
249"goto" { thrift_reserved_keyword(yytext); }
250"if" { thrift_reserved_keyword(yytext); }
251"implements" { thrift_reserved_keyword(yytext); }
252"import" { thrift_reserved_keyword(yytext); }
253"in" { thrift_reserved_keyword(yytext); }
254"inline" { thrift_reserved_keyword(yytext); }
255"instanceof" { thrift_reserved_keyword(yytext); }
256"interface" { thrift_reserved_keyword(yytext); }
257"is" { thrift_reserved_keyword(yytext); }
258"lambda" { thrift_reserved_keyword(yytext); }
Bryan Duxbury7f3285e2010-08-05 23:28:14 +0000259"module" { thrift_reserved_keyword(yytext); }
Mark Sleebd588222007-11-21 08:43:35 +0000260"native" { thrift_reserved_keyword(yytext); }
261"new" { thrift_reserved_keyword(yytext); }
Bryan Duxbury7f3285e2010-08-05 23:28:14 +0000262"next" { thrift_reserved_keyword(yytext); }
263"nil" { thrift_reserved_keyword(yytext); }
Mark Sleebd588222007-11-21 08:43:35 +0000264"not" { thrift_reserved_keyword(yytext); }
265"or" { thrift_reserved_keyword(yytext); }
Jens Geyere33d1652015-07-24 02:14:43 +0200266"package" { thrift_reserved_keyword(yytext); }
Mark Sleebd588222007-11-21 08:43:35 +0000267"pass" { thrift_reserved_keyword(yytext); }
268"public" { thrift_reserved_keyword(yytext); }
269"print" { thrift_reserved_keyword(yytext); }
270"private" { thrift_reserved_keyword(yytext); }
271"protected" { thrift_reserved_keyword(yytext); }
Bryan Duxbury7f3285e2010-08-05 23:28:14 +0000272"public" { thrift_reserved_keyword(yytext); }
Mark Sleebd588222007-11-21 08:43:35 +0000273"raise" { thrift_reserved_keyword(yytext); }
Bryan Duxbury7f3285e2010-08-05 23:28:14 +0000274"redo" { thrift_reserved_keyword(yytext); }
275"rescue" { thrift_reserved_keyword(yytext); }
276"retry" { thrift_reserved_keyword(yytext); }
Mark Sleef5a0b3d2009-08-13 19:21:40 +0000277"register" { thrift_reserved_keyword(yytext); }
Mark Sleebd588222007-11-21 08:43:35 +0000278"return" { thrift_reserved_keyword(yytext); }
Bryan Duxbury7f3285e2010-08-05 23:28:14 +0000279"self" { thrift_reserved_keyword(yytext); }
Mark Sleebd588222007-11-21 08:43:35 +0000280"sizeof" { thrift_reserved_keyword(yytext); }
281"static" { thrift_reserved_keyword(yytext); }
Bryan Duxbury7f3285e2010-08-05 23:28:14 +0000282"super" { thrift_reserved_keyword(yytext); }
Mark Sleebd588222007-11-21 08:43:35 +0000283"switch" { thrift_reserved_keyword(yytext); }
284"synchronized" { thrift_reserved_keyword(yytext); }
Bryan Duxbury7f3285e2010-08-05 23:28:14 +0000285"then" { thrift_reserved_keyword(yytext); }
Mark Sleebd588222007-11-21 08:43:35 +0000286"this" { thrift_reserved_keyword(yytext); }
287"throw" { thrift_reserved_keyword(yytext); }
288"transient" { thrift_reserved_keyword(yytext); }
Mark Sleebd588222007-11-21 08:43:35 +0000289"try" { thrift_reserved_keyword(yytext); }
Bryan Duxbury7f3285e2010-08-05 23:28:14 +0000290"undef" { thrift_reserved_keyword(yytext); }
291"union" { thrift_reserved_keyword(yytext); }
292"unless" { thrift_reserved_keyword(yytext); }
Mark Sleebd588222007-11-21 08:43:35 +0000293"unsigned" { thrift_reserved_keyword(yytext); }
Bryan Duxbury7f3285e2010-08-05 23:28:14 +0000294"until" { thrift_reserved_keyword(yytext); }
295"use" { thrift_reserved_keyword(yytext); }
Mark Sleebd588222007-11-21 08:43:35 +0000296"var" { thrift_reserved_keyword(yytext); }
297"virtual" { thrift_reserved_keyword(yytext); }
298"volatile" { thrift_reserved_keyword(yytext); }
Bryan Duxbury7f3285e2010-08-05 23:28:14 +0000299"when" { thrift_reserved_keyword(yytext); }
Mark Sleebd588222007-11-21 08:43:35 +0000300"while" { thrift_reserved_keyword(yytext); }
301"with" { thrift_reserved_keyword(yytext); }
Bryan Duxbury7f3285e2010-08-05 23:28:14 +0000302"xor" { thrift_reserved_keyword(yytext); }
Mark Sleebd588222007-11-21 08:43:35 +0000303"yield" { thrift_reserved_keyword(yytext); }
Mark Sleef12865a2007-01-12 00:23:26 +0000304
Mark Slee4f8da1d2006-10-12 02:47:27 +0000305{intconstant} {
David Reissf1454162008-06-30 20:45:47 +0000306 errno = 0;
307 yylval.iconst = strtoll(yytext, NULL, 10);
308 if (errno == ERANGE) {
309 integer_overflow(yytext);
310 }
Mark Slee4f8da1d2006-10-12 02:47:27 +0000311 return tok_int_constant;
312}
Mark Sleef5377b32006-10-10 01:42:59 +0000313
Mark Slee600cdb32006-11-29 22:06:42 +0000314{hexconstant} {
David Reissf1454162008-06-30 20:45:47 +0000315 errno = 0;
Jens Geyer5ec21212015-04-26 15:24:59 +0200316 char sign = yytext[0];
317 int shift = sign == '0' ? 2 : 3;
318 yylval.iconst = strtoll(yytext+shift, NULL, 16);
319 if (sign == '-') {
320 yylval.iconst = -yylval.iconst;
321 }
David Reissf1454162008-06-30 20:45:47 +0000322 if (errno == ERANGE) {
323 integer_overflow(yytext);
324 }
Mark Slee600cdb32006-11-29 22:06:42 +0000325 return tok_int_constant;
326}
327
Mark Slee30152872006-11-28 01:24:07 +0000328{dubconstant} {
329 yylval.dconst = atof(yytext);
330 return tok_dub_constant;
331}
332
Mark Slee4f8da1d2006-10-12 02:47:27 +0000333{identifier} {
334 yylval.id = strdup(yytext);
335 return tok_identifier;
336}
337
Mark Sleebd588222007-11-21 08:43:35 +0000338{st_identifier} {
339 yylval.id = strdup(yytext);
340 return tok_st_identifier;
341}
342
David Reiss82e6fc02009-03-26 23:32:36 +0000343{literal_begin} {
344 char mark = yytext[0];
345 std::string result;
346 for(;;)
347 {
348 int ch = yyinput();
349 switch (ch) {
350 case EOF:
351 yyerror("End of file while read string at %d\n", yylineno);
352 exit(1);
353 case '\n':
354 yyerror("End of line while read string at %d\n", yylineno - 1);
355 exit(1);
356 case '\\':
357 ch = yyinput();
358 switch (ch) {
359 case 'r':
360 result.push_back('\r');
361 continue;
362 case 'n':
363 result.push_back('\n');
364 continue;
365 case 't':
366 result.push_back('\t');
367 continue;
368 case '"':
369 result.push_back('"');
370 continue;
371 case '\'':
372 result.push_back('\'');
373 continue;
374 case '\\':
375 result.push_back('\\');
376 continue;
377 default:
378 yyerror("Bad escape character\n");
379 return -1;
380 }
381 break;
382 default:
383 if (ch == mark) {
384 yylval.id = strdup(result.c_str());
385 return tok_literal;
386 } else {
387 result.push_back(ch);
388 }
389 }
390 }
Mark Slee30152872006-11-28 01:24:07 +0000391}
392
Mark Slee31985722006-05-24 21:45:31 +0000393
ccheeverf53b5cf2007-02-05 20:33:11 +0000394{doctext} {
David Reisscbd4bac2007-08-14 17:12:33 +0000395 /* This does not show up in the parse tree. */
396 /* Rather, the parser will grab it out of the global. */
397 if (g_parse_mode == PROGRAM) {
398 clear_doctext();
399 g_doctext = strdup(yytext + 3);
Jens Geyer8cd3efe2013-09-16 22:17:52 +0200400 assert(strlen(g_doctext) >= 2);
401 g_doctext[strlen(g_doctext) - 2] = ' ';
402 g_doctext[strlen(g_doctext) - 1] = '\0';
David Reisscbd4bac2007-08-14 17:12:33 +0000403 g_doctext = clean_up_doctext(g_doctext);
404 g_doctext_lineno = yylineno;
Jens Geyer813749d2014-01-31 23:42:57 +0100405 if( (g_program_doctext_candidate == NULL) && (g_program_doctext_status == INVALID)){
Jens Geyere8379b52014-01-25 00:59:45 +0100406 g_program_doctext_candidate = strdup(g_doctext);
407 g_program_doctext_lineno = g_doctext_lineno;
408 g_program_doctext_status = STILL_CANDIDATE;
Jens Geyer813749d2014-01-31 23:42:57 +0100409 pdebug("%s","program doctext set to STILL_CANDIDATE");
Jens Geyere8379b52014-01-25 00:59:45 +0100410 }
David Reisscbd4bac2007-08-14 17:12:33 +0000411 }
ccheeverf53b5cf2007-02-05 20:33:11 +0000412}
413
Bryan Duxbury235f8b52011-08-19 18:27:47 +0000414. {
415 unexpected_token(yytext);
416}
417
ccheeverf53b5cf2007-02-05 20:33:11 +0000418
David Reissfb790d72010-09-02 16:41:45 +0000419. {
420 /* Catch-all to let us catch "*" in the parser. */
421 return (int) yytext[0];
422}
423
Mark Slee31985722006-05-24 21:45:31 +0000424%%
David Reiss4a054342009-03-26 23:32:27 +0000425
426/* vim: filetype=lex
427*/