]> git.saurik.com Git - bison.git/blob - src/scan-skel.l
* src/skeleton.h: New.
[bison.git] / src / scan-skel.l
1 /* -*- C -*- */
2 /* Scan Bison Skeletons.
3 Copyright (C) 2001 Free Software Foundation, Inc.
4
5 This file is part of Bison, the GNU Compiler Compiler.
6
7 Bison is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 Bison is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Bison; see the file COPYING. If not, write to the Free
19 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA. */
21
22 %{
23
24 #include "system.h"
25 #include "skeleton.h"
26 #include "parse-skel.h"
27
28 %}
29
30 %option nounput
31 %option noyywrap
32 /* If we enable
33
34 %option yylineno
35
36 Then we have warning: `yy_flex_realloc' defined but not used.
37 Seems like a Flex bug to me: Why the heck yylineno would trigger
38 the REJECT exception??? */
39
40 %%
41
42 "%%{line}" { return LINE; }
43 "%%{skeleton-line}" { return SLINE; }
44
45 "%%{yacc}" { return YACC; }
46 "%%{section}" { return SECTION; }
47
48 "%%{guards}" { return GUARDS; }
49 "%%{actions}" { return ACTIONS; }
50 "%%{tokendef}" { return TOKENS; }
51
52 "%%{"[a-zA-Z][0-9a-zA-Z_-]+"}" { /* Muscle. */
53 size_t len = strlen (yytext);
54 yylval.string = (char*) malloc (len - 3);
55 strncpy (yylval.string, yytext + 3, len - 4);
56 yylval.string[len - 4] = 0;
57 return MUSCLE;
58 }
59
60 "%%\"".*"\"" { /* String. */
61 size_t len = strlen (yytext);
62 yylval.string = (char*) malloc (len - 3);
63 strncpy (yylval.string, yytext + 3, len - 4);
64 yylval.string[len - 4] = 0;
65 return STRING;
66 }
67
68 <<EOF>> { /* End of file. */
69 return 0;
70 }
71
72 "\n" { /* End of line. */
73 return '\n';
74 }
75
76 . { /* Character. */
77 yylval.character = *yytext;
78 return CHARACTER;
79 }
80
81 %%