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.yy | |
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.yy')
-rw-r--r-- | src/system.yy | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/src/system.yy b/src/system.yy index 3e990c5..73134bc 100644 --- a/src/system.yy +++ b/src/system.yy @@ -26,15 +26,15 @@ bool legacy = true; { #include <cstdint> #include "lexer.h" -#include "system.loc.hh" +#include "location.h" } //%locations //%define api.location.type {yy::location} %parse-param {Lexer<symbol_type> &lexer} -%token <uint64_t> NUM -%token <double> FRC +%token <uint64_t> ULONG +%token <double> FLOAT %token <int> KEY %token BREAK BLANK START END VERSION CPU BASE USER NICE SWAP %token SYSP IDLE IOWP IRQP SIRQ CORE MEM TOTAL AVAIL CACHE TSENSOR @@ -53,16 +53,16 @@ block: ; block_start: - START BLANK NUM BREAK { - cout << "begin\t" << $NUM << endl; + START BLANK ULONG BREAK { + cout << "begin\t" << $ULONG << endl; msg.set_epoch($<uint64_t>3); } ; block_end: - END BLANK NUM BREAK { + END BLANK ULONG BREAK { if ($<uint64_t>3 == msg.epoch()) { - cout << "end\t" << $NUM << endl; + cout << "end\t" << $ULONG << endl; auto p = filesystem::path("proto"); p /= to_string($<uint64_t>3); p += string(".proto"); @@ -79,7 +79,7 @@ data_block: ; version_block: - VERSION BLANK NUM BLANK NUM BREAK { + VERSION BLANK ULONG BLANK ULONG BREAK { legacy = false; cout << "ver\t" << $3 << "\t" << $5 << endl; } @@ -104,14 +104,14 @@ cpu_percent: | SIRQ { $<int>$ = 6; }; cpu_block: - BASE BLANK FRC BLANK NUM { + BASE BLANK FLOAT BLANK ULONG { ([&] (auto base) { base->set_usage($<double>3); base->set_clock($<uint64_t>5); cout << "cpu\tbase\t" << base->usage() << "\t" << base->clock() << endl; })(msg.mutable_cpu()->mutable_base()); } - | cpu_percent BLANK FRC BLANK FRC { + | cpu_percent BLANK FLOAT BLANK FLOAT { string name = ([&](auto t) { cout << t; switch(t) { @@ -136,7 +136,7 @@ cpu_block: })($<double>3, $<double>5); } - | CORE NUM BLANK FRC BLANK NUM { + | CORE ULONG BLANK FLOAT BLANK ULONG { ([&] (auto core, auto a, auto b) -> void { ::Entry::CPUStats_Core c; c.set_usage(a); @@ -160,7 +160,7 @@ mem_type: ; mem_current: - mem_type BLANK NUM { + mem_type BLANK ULONG { ([&](auto mem, int t, uint64_t v) { cout << "mem\t"; switch(t) { @@ -177,9 +177,9 @@ mem_current: } ; -tmp_current_type: CURR | TMIN | TMAX | TAVG; +tmp_type: CURR | TMIN | TMAX | TAVG; tmp_current: - tmp_current_type BLANK NUM { + tmp_type BLANK ULONG { if (legacy) throw syntax_error("TEMP Block in legacy data."); using token = yy::parser::token::token_kind_type; @@ -205,7 +205,7 @@ cpu_legacy_list: mem_legacy: mem_legacy_total mem_legacy_list BREAK; mem_legacy_total: - MEM BLANK NUM { + MEM BLANK ULONG { msg.mutable_mem()->set_total($<uint64_t>3); cout << "mem\t" << msg.mem().total(); } @@ -217,7 +217,7 @@ mem_legacy_list: ; mem_legacy_ram: - mem_legacy_type COLON NUM { + mem_legacy_type COLON ULONG { ([&](auto mem, int t, uint64_t v) { switch(t) { case token_type::AVAIL: mem->set_avail(v); cout << "\tavail:" << msg.mem().avail(); break; @@ -231,7 +231,7 @@ mem_legacy_ram: mem_legacy_data: mem_legacy_ram - | SWAP COLON NUM SLASH NUM { + | SWAP COLON ULONG SLASH ULONG { msg.mutable_mem()->set_tswap($<uint64_t>5); msg.mutable_mem()->set_uswap($<uint64_t>3); cout << "\tswap:" << msg.mem().uswap() << "/" << msg.mem().tswap() << endl; @@ -251,9 +251,8 @@ tmp_legacy_block: tmp_legacy_list: BLANK tmp_legacy_data | tmp_legacy_list BLANK tmp_legacy_data; -tmp_legacy_type: CURR | TMIN | TMAX | TAVG; tmp_legacy_data: - tmp_legacy_type COLON NUM { + tmp_type COLON ULONG { using token = yy::parser::token::token_kind_type; ([&](auto tmp, token t, uint64_t v) { switch(t) { |