Found my old LEL code and got the shell working, so tomorrow I'll try to make it layout some gui element.
This commit is contained in:
parent
8a6b38c1a4
commit
bfd2718cc9
8 changed files with 485 additions and 3 deletions
87
lel.rl
Normal file
87
lel.rl
Normal file
|
@ -0,0 +1,87 @@
|
|||
#include "lel.hpp"
|
||||
#include <fmt/core.h>
|
||||
|
||||
%%{
|
||||
machine LELParser;
|
||||
alphtype char;
|
||||
|
||||
action token {tk = input.substr(start - begin, fpc - start); }
|
||||
|
||||
action col { col(); }
|
||||
action ltab { ltab(); }
|
||||
action valign { valign(fc); }
|
||||
action id { id(input.substr(start - begin, fpc - start)); }
|
||||
action row { row(); }
|
||||
action align { align(fc); }
|
||||
action setwidth { setwidth(std::stoi(tk)); }
|
||||
action setheight { setheight(std::stoi(tk)); }
|
||||
action expand { expand(); }
|
||||
|
||||
col = "|" $col;
|
||||
ltab = "[" $ltab;
|
||||
rtab = "]" $row;
|
||||
valign = ("^" | ".") $valign;
|
||||
expand = "*" $expand;
|
||||
halign = ("<" | ">") $align;
|
||||
number = digit+ >{ start = fpc; } %token;
|
||||
setw = ("(" number %setwidth ("," number %setheight)? ")") ;
|
||||
modifiers = (expand | valign | halign | setw);
|
||||
id = modifiers* ((alpha | '_')+ :>> (alnum | '_')*) >{start = fpc;} %id;
|
||||
row = space* ltab space* id space* (col space* id)* space* rtab space*;
|
||||
|
||||
main := row+;
|
||||
}%%
|
||||
|
||||
%% write data;
|
||||
|
||||
bool LELParser::parse(std::string input) {
|
||||
int cs = 0;
|
||||
const char *start = nullptr;
|
||||
const char *begin = input.data();
|
||||
const char *p = input.data();
|
||||
const char *pe = p + input.size();
|
||||
std::string tk;
|
||||
|
||||
%% write init;
|
||||
%% write exec;
|
||||
|
||||
bool good = pe - p == 0;
|
||||
|
||||
return good;
|
||||
}
|
||||
|
||||
void LELParser::col() {
|
||||
fmt::println("col");
|
||||
}
|
||||
|
||||
void LELParser::ltab() {
|
||||
fmt::println("ltab");
|
||||
}
|
||||
|
||||
void LELParser::valign(char dir) {
|
||||
fmt::println("valign: {}", dir);
|
||||
}
|
||||
|
||||
void LELParser::align(char dir) {
|
||||
fmt::println("align {}", dir);
|
||||
}
|
||||
|
||||
void LELParser::id(std::string name) {
|
||||
fmt::println("id: {}", name);
|
||||
}
|
||||
|
||||
void LELParser::row() {
|
||||
fmt::println("row");
|
||||
}
|
||||
|
||||
void LELParser::setwidth(int width) {
|
||||
fmt::println("setwidth: {}", width);
|
||||
}
|
||||
|
||||
void LELParser::setheight(int height) {
|
||||
fmt::println("setheight: {}", height);
|
||||
}
|
||||
|
||||
void LELParser::expand() {
|
||||
fmt::println("expand");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue