naspro

view permafrost/src/scanner.l @ 178:7169a8909d53

Added Permafrost + small changes
author Stefano D'Angelo <zanga.mail@gmail.com>
date Sun May 02 14:19:58 2010 +0300 (2010-05-02)
parents
children
line source
1 %{
2 /*
3 * Permafrost - Physical modelling framework
4 *
5 * Copyright (C) 2009, 2010 Stefano D'Angelo <zanga.mail@gmail.com>
6 *
7 * See the COPYING file for license conditions.
8 */
10 #include "src/types.h"
11 #include "src/util.h"
12 #include "src/parser.tab.h"
14 #define YY_USER_ACTION \
15 yylloc->first_line = yylineno; \
16 yylloc->first_column = yycolumn; \
17 yycolumn += yyleng; \
18 yylloc->last_line = yylloc->first_line; \
19 yylloc->last_column = yycolumn - 1;
20 %}
22 NEWLINE (\n|\n\r|\r\n)
24 %option header-file="src/scanner.h"
25 %option outfile="src/scanner.c"
26 %option batch
27 %option 8bit
28 %option noyywrap
29 %option bison-bridge
30 %option bison-locations
31 %option reentrant
32 %option nounistd
33 %option full
34 %option warn
35 %option nounput
36 %option never-interactive
38 %%
40 [ ] /* eat spaces */ ;
41 \t yycolumn += 7; yylloc->last_column += 7; /* eat tabs */
42 {NEWLINE} yylloc->last_line = ++yylineno; yylloc->last_column = yycolumn = 0; /* eat newlines */
43 #.* /* eat comments */ ;
45 import return IMPORT;
46 const return CONST;
47 ext_function return EXT_FUNCTION;
48 block return BLOCK;
49 macro return MACRO;
50 system return SYSTEM;
51 sync return SYNC;
52 async return ASYNC;
53 input return INPUT;
54 output return OUTPUT;
55 w_port return W_PORT;
56 k_port return K_PORT;
57 in return IN;
58 out return OUT;
59 sample_rate return SAMPLE_RATE;
61 ; return SEMICOLON;
62 \{ return LBRACE;
63 \} return RBRACE;
64 \. return DOT;
65 , return COMA;
66 = return EQUALS;
67 \+ return PLUS;
68 \- return MINUS;
69 \* return ASTERISK;
70 \/ return SLASH;
71 \( return LPAR;
72 \) return RPAR;
73 \[ return LSBRACKET;
74 \] return RSBRACKET;
76 [A-Za-z_][A-Za-z0-9_]* yylval->str = copy_str(yytext); return ID;
77 \"[A-Za-z0-9_\\/\-\.]*\" yylval->str = copy_str_no_q(yytext); return STRING;
79 0|[1-9][0-9]* sscanf(yytext, "%lu", &yylval->l); return INTEGER;
80 (0?|[1-9]*[0-9]*)\.[0-9]+([eE][\+\-]?[0-9]+)?|(0|[1-9][0-9]*)\.([eE][\+\-]?[0-9]+)? sscanf(yytext, "%lf", &yylval->val); return FLOAT;
82 . return yytext[0];
84 %%