]> git.saurik.com Git - bison.git/blame - src/scan-skel.l
* src/bison.simple, src/bison.hairy, src/bison.c++: Move to...
[bison.git] / src / scan-skel.l
CommitLineData
1239777d
AD
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.
9b3add5b 16
1239777d
AD
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. */
9b3add5b 21
aed7fd9b
AD
22%option debug nodefault noyywrap nounput
23%option prefix="skel_" outfile="lex.yy.c"
9b3add5b 24
1239777d
AD
25/* If we enable
26
27 %option yylineno
28
29 Then we have warning: `yy_flex_realloc' defined but not used.
30 Seems like a Flex bug to me: Why the heck yylineno would trigger
31 the REJECT exception??? */
9b3add5b 32
aed7fd9b
AD
33%{
34#include "system.h"
35#include "skeleton.h"
36#include "parse-skel.h"
37%}
38
39%{
40/* Each time we match a string, move the end cursor to its end. */
41#define YY_USER_ACTION yylloc->last_column += yyleng;
42%}
9b3add5b 43%%
aed7fd9b
AD
44%{
45 /* At each yylex invocation, mark the current position as the
46 start of the next token. */
47 LOCATION_STEP (*yylloc);
48%}
9b3add5b
RA
49
50"%%{line}" { return LINE; }
51"%%{skeleton-line}" { return SLINE; }
52
9b3add5b
RA
53"%%{section}" { return SECTION; }
54
55"%%{guards}" { return GUARDS; }
56"%%{actions}" { return ACTIONS; }
57"%%{tokendef}" { return TOKENS; }
58
a4b36db4
AD
59 /* Muscle. */
60"%%{"[a-zA-Z][0-9a-zA-Z_-]+"}" {
aed7fd9b 61 yylval->string = xstrndup (yytext + 3, yyleng - 4);
9b3add5b
RA
62 return MUSCLE;
63}
64
a4b36db4
AD
65 /* String. */
66"%%\"".*"\"" {
aed7fd9b 67 yylval->string = xstrndup (yytext + 3, yyleng - 4);
9b3add5b
RA
68 return STRING;
69}
70
a4b36db4
AD
71 /* End of line. */
72"\n" {
aed7fd9b 73 LOCATION_LINES (*yylloc, yyleng);
9b3add5b
RA
74 return '\n';
75}
76
24fad99e
AD
77 /* White spaces. */
78[\t ]+ {
aed7fd9b 79 yylval->string = yytext;
24fad99e
AD
80 return BLANKS;
81}
82
aed7fd9b
AD
83 /* Plain Characters. */
84[^%\n]+ {
85 yylval->string = yytext;
86 return RAW;
87}
88
a4b36db4
AD
89 /* Plain Character. */
90. {
aed7fd9b 91 yylval->character = *yytext;
9b3add5b
RA
92 return CHARACTER;
93}
94
95%%