diff options
author | 2024-11-15 17:25:44 +0600 | |
---|---|---|
committer | 2024-11-15 17:25:44 +0600 | |
commit | 5a02f27098f62f4bfac015c2ed4023715a7d1c33 (patch) | |
tree | 683e7e70bcfc1153a4abb17e6f8dc1942a25258f /src/system.flex | |
parent | 2eb3342f0a09b23db4dbf3518778fe7379acccdf (diff) | |
download | log-parser-5a02f27098f62f4bfac015c2ed4023715a7d1c33.tar.gz log-parser-5a02f27098f62f4bfac015c2ed4023715a7d1c33.zip |
Use saner name for types and add location definition
Signed-off-by: Mubashshir <ahmubashshir@gmail.com>
Diffstat (limited to 'src/system.flex')
-rw-r--r-- | src/system.flex | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/system.flex b/src/system.flex new file mode 100644 index 0000000..e5da5d2 --- /dev/null +++ b/src/system.flex @@ -0,0 +1,65 @@ +/* Tokens */ +%option c++ +%option noyywrap +%option debug +%option yyclass="Lexer" +%option yylineno + +%{ +#include <iostream> +#include "system.tab.hh" +#include "location.h" + +#undef YY_DECL +# define YY_DECL template<> parser::symbol_type Lexer<parser::symbol_type>::yynlex () + +using parser = yy::parser; +using namespace std; +%} + +digit [0-9] +num {digit}+ +frc {digit}+\.{digit}+ +%% +{frc} { return parser::make_FLOAT(atof(yytext_ptr)); } +{num} { return parser::make_ULONG(atoi(yytext_ptr)); } + +[\n] { return parser::make_BREAK();} +[\t] { return parser::make_BLANK();} +begin { return parser::make_START(); } +end { return parser::make_END(); } +ver { return parser::make_VERSION(); } +cpu { return parser::make_CPU(); } +base { return parser::make_BASE(); } +user% { return parser::make_USER(); } +nice% { return parser::make_NICE(); } +system% { return parser::make_SYSP(); } +idle% { return parser::make_IDLE(); } +iowait% { return parser::make_IOWP(); } +irq% { return parser::make_IRQP(); } +swirq% { return parser::make_SIRQ(); } +core: { return parser::make_CORE(); } + +mem { return parser::make_MEM(); } +total { return parser::make_TOTAL(); } +avail { return parser::make_AVAIL(); } +cache { return parser::make_CACHE(); } +share { return parser::make_SHARED(); } +swap { return parser::make_SWAP(); } +tswap { return parser::make_TSWAP(); } +uswap { return parser::make_USWAP(); } + +tmp { return parser::make_TEMP(); } +cur { return parser::make_CURR(); } +min { return parser::make_TMIN(); } +max { return parser::make_TMAX(); } +avg { return parser::make_TAVG(); } + +: { return parser::make_COLON(); } +\/ { return parser::make_SLASH(); } + +Package\ id\ {num} {return parser::make_TSENSOR();}; + +. { /* everything else */ } + +%% |