1
0
mirror of https://github.com/stedolan/jq.git synced 2024-05-11 05:55:39 +00:00
stedolan-jq/c/lexer.l

52 lines
1.2 KiB
Plaintext
Raw Normal View History

2012-08-16 01:00:30 +01:00
%{
#include "compile.h"
#include "parser.tab.h" /* Generated by bison. */
#define YY_USER_ACTION \
do { \
yylloc->start = yyget_extra(yyscanner); \
yylloc->end = yylloc->start + yyleng; \
yyset_extra(yylloc->end, yyscanner); \
} while (0);
2012-08-16 01:00:30 +01:00
%}
%option noyywrap nounput noinput nodefault
%option reentrant
%option extra-type="int"
2012-08-16 01:00:30 +01:00
%option bison-bridge bison-locations
%%
"==" { return EQ; }
"as" { return AS; }
2012-08-21 18:14:13 +01:00
"def" { return DEF; }
2012-08-27 10:11:55 +01:00
"|=" { return SETPIPE; }
2012-09-04 15:34:34 +01:00
"if" { return IF; }
"then" { return THEN; }
"else" { return ELSE; }
2012-09-04 16:05:24 +01:00
"elif" { return ELSE_IF; }
"and" { return AND; }
"or" { return OR; }
"not" { return NOT; }
2012-09-04 15:34:34 +01:00
"end" { return END; }
"//" { return DEFINEDOR; }
"."|"="|";"|"["|"]"|","|":"|"("|")"|"{"|"}"|"|"|"+"|"-"|"*"|"/"|"\$" { return yytext[0];}
2012-08-16 01:00:30 +01:00
\"(\\.|[^\\"])*\" |
-?[0-9.]+([eE][+-]?[0-9]+)? {
yylval->literal = jv_parse_sized(yytext, yyleng); return LITERAL;
}
[[:alnum:]]+ { yylval->literal = jv_string(yytext); return IDENT;}
2012-08-16 01:00:30 +01:00
[ \n\t]+ {}
2012-08-16 01:00:30 +01:00
%%
/* perhaps these should be calls... */
/*
"true" { return TRUE; }
"false" { return FALSE; }
"null" { return NULL; }
*/