]> git.saurik.com Git - bison.git/blob - src/scan-skel.l
* src/muscle_tab.h (MUSCLE_INSERT_INT, MUSCLE_INSERT_STRING)
[bison.git] / src / scan-skel.l
1 %{
2
3 #include <stdlib.h>
4 #include <string.h>
5
6 #include "parse-skel.h"
7
8 %}
9
10 %option nounput
11 %option noyywrap
12 %option yylineno
13
14 %%
15
16 "%%{line}" { return LINE; }
17 "%%{skeleton-line}" { return SLINE; }
18
19 "%%{yacc}" { return YACC; }
20 "%%{section}" { return SECTION; }
21
22 "%%{guards}" { return GUARDS; }
23 "%%{actions}" { return ACTIONS; }
24 "%%{tokendef}" { return TOKENS; }
25
26 "%%{"[a-zA-Z][0-9a-zA-Z_-]+"}" { /* Muscle. */
27 size_t len = strlen (yytext);
28 yylval.string = (char*) malloc (len - 3);
29 strncpy (yylval.string, yytext + 3, len - 4);
30 yylval.string[len - 4] = 0;
31 return MUSCLE;
32 }
33
34 "%%\"".*"\"" { /* String. */
35 size_t len = strlen (yytext);
36 yylval.string = (char*) malloc (len - 3);
37 strncpy (yylval.string, yytext + 3, len - 4);
38 yylval.string[len - 4] = 0;
39 return STRING;
40 }
41
42 <<EOF>> { /* End of file. */
43 return 0;
44 }
45
46 "\n" { /* End of line. */
47 return '\n';
48 }
49
50 . { /* Character. */
51 yylval.character = *yytext;
52 return CHARACTER;
53 }
54
55 %%