-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhcl.lex
45 lines (42 loc) · 1.53 KB
/
hcl.lex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
%{
#include <stdio.h>
#include "node.h"
#define YYSTYPE node_ptr
#include "hcl.tab.h"
extern YYSTYPE yylval;
extern int lineno;
%}
%%
[ \r\t\f] ;
[\n] lineno++;
"#".*\n lineno++ ;
quote return(QUOTE);
boolsig return(BOOLARG);
bool return(BOOL);
wordsig return(WORDARG);
word return(WORD);
in return(IN);
'[^']*' yylval = make_quote(yytext); return(QSTRING);
[a-zA-Z][a-zA-Z0-9_]* yylval = make_var(yytext); return(VAR);
[0-9][0-9]* yylval = make_num(yytext); return(NUM);
-[0-9][0-9]* yylval = make_num(yytext); return(NUM);
"=" return(ASSIGN);
";" return(SEMI);
":" return(COLON);
"," return(COMMA);
"(" return(LPAREN);
")" return(RPAREN);
"{" return(LBRACE);
"}" return(RBRACE);
"[" return(LBRACK);
"]" return(RBRACK);
"&&" return(AND);
"||" return(OR);
"!=" yylval = make_var(yytext); return(COMP);
"==" yylval = make_var(yytext); return(COMP);
"<" yylval = make_var(yytext); return(COMP);
"<=" yylval = make_var(yytext); return(COMP);
">" yylval = make_var(yytext); return(COMP);
">=" yylval = make_var(yytext); return(COMP);
"!" return(NOT);
%%