LEL is working at a basic grid level, able to render boxes where I want.

This commit is contained in:
Zed A. Shaw 2025-02-15 01:31:57 -05:00
parent 846b7aaf16
commit 872cedc8e1
8 changed files with 127 additions and 99 deletions

View file

@ -2,13 +2,14 @@
#line 1 "lel_parser.rl"
#include "lel.hpp"
#include <fmt/core.h>
#include <iostream>
#line 33 "lel_parser.rl"
#line 34 "lel_parser.rl"
#line 7 "lel_parser.cpp"
#line 8 "lel_parser.cpp"
static const char _LELParser_actions[] = {
0, 1, 1, 1, 2, 1, 3, 1,
4, 1, 5, 1, 6, 1, 9, 1,
@ -18,8 +19,7 @@ static const char _LELParser_actions[] = {
static const char _LELParser_key_offsets[] = {
0, 0, 4, 18, 20, 24, 35, 47,
52, 66, 68, 72, 83, 95, 99, 101,
104, 106, 109
52, 54, 57
};
static const char _LELParser_trans_keys[] = {
@ -29,33 +29,23 @@ static const char _LELParser_trans_keys[] = {
40, 42, 46, 60, 62, 94, 95, 65,
90, 97, 122, 32, 93, 95, 124, 9,
13, 48, 57, 65, 90, 97, 122, 32,
93, 124, 9, 13, 32, 40, 42, 46,
60, 62, 94, 95, 9, 13, 65, 90,
97, 122, 48, 57, 41, 44, 48, 57,
40, 42, 46, 60, 62, 94, 95, 65,
90, 97, 122, 32, 93, 95, 124, 9,
13, 48, 57, 65, 90, 97, 122, 32,
93, 9, 13, 48, 57, 41, 48, 57,
48, 57, 41, 48, 57, 32, 91, 9,
13, 0
93, 124, 9, 13, 48, 57, 41, 48,
57, 32, 91, 9, 13, 0
};
static const char _LELParser_single_lengths[] = {
0, 2, 8, 0, 2, 7, 4, 3,
8, 0, 2, 7, 4, 2, 0, 1,
0, 1, 2
};
static const char _LELParser_range_lengths[] = {
0, 1, 3, 1, 1, 2, 4, 1,
3, 1, 1, 2, 4, 1, 1, 1,
1, 1, 1
};
static const char _LELParser_index_offsets[] = {
0, 0, 4, 16, 18, 22, 32, 41,
46, 58, 60, 64, 74, 83, 87, 89,
92, 94, 97
46, 48, 51
};
static const char _LELParser_indicies[] = {
@ -64,40 +54,30 @@ static const char _LELParser_indicies[] = {
9, 1, 10, 11, 12, 1, 4, 5,
6, 7, 7, 6, 8, 8, 8, 1,
13, 15, 14, 16, 13, 14, 14, 14,
1, 17, 18, 19, 17, 1, 20, 21,
22, 23, 24, 24, 23, 25, 20, 25,
25, 1, 26, 1, 27, 28, 29, 1,
21, 22, 23, 24, 24, 23, 25, 25,
25, 1, 30, 15, 31, 16, 30, 31,
31, 31, 1, 32, 18, 32, 1, 33,
1, 34, 35, 1, 36, 1, 37, 38,
1, 39, 2, 39, 1, 0
1, 17, 18, 19, 17, 1, 20, 1,
21, 22, 1, 23, 2, 23, 1, 0
};
static const char _LELParser_trans_targs[] = {
1, 0, 2, 2, 3, 5, 5, 5,
6, 4, 5, 16, 4, 7, 6, 18,
8, 7, 18, 8, 8, 9, 11, 11,
11, 12, 10, 11, 14, 10, 13, 12,
13, 15, 11, 15, 17, 5, 17, 18
6, 4, 5, 8, 4, 7, 6, 10,
2, 7, 10, 2, 9, 5, 9, 10
};
static const char _LELParser_trans_actions[] = {
0, 0, 3, 0, 0, 13, 5, 11,
17, 15, 19, 19, 0, 7, 0, 28,
25, 0, 9, 1, 0, 0, 13, 5,
11, 17, 15, 19, 19, 0, 7, 0,
0, 15, 22, 0, 15, 22, 0, 0
25, 0, 9, 1, 15, 22, 0, 0
};
static const int LELParser_start = 1;
static const int LELParser_first_final = 18;
static const int LELParser_first_final = 10;
static const int LELParser_error = 0;
static const int LELParser_en_main = 1;
#line 36 "lel_parser.rl"
#line 37 "lel_parser.rl"
bool LELParser::parse(std::string input) {
reset();
@ -109,14 +89,14 @@ bool LELParser::parse(std::string input) {
std::string tk;
#line 104 "lel_parser.cpp"
#line 84 "lel_parser.cpp"
{
cs = LELParser_start;
}
#line 47 "lel_parser.rl"
#line 48 "lel_parser.rl"
#line 107 "lel_parser.cpp"
#line 87 "lel_parser.cpp"
{
int _klen;
unsigned int _trans;
@ -191,54 +171,54 @@ _match:
switch ( *_acts++ )
{
case 0:
#line 8 "lel_parser.rl"
#line 9 "lel_parser.rl"
{tk = input.substr(start - begin, p - start); }
break;
case 1:
#line 10 "lel_parser.rl"
#line 11 "lel_parser.rl"
{ col(); }
break;
case 2:
#line 11 "lel_parser.rl"
#line 12 "lel_parser.rl"
{ ltab(); }
break;
case 3:
#line 12 "lel_parser.rl"
#line 13 "lel_parser.rl"
{ valign((*p)); }
break;
case 4:
#line 13 "lel_parser.rl"
#line 14 "lel_parser.rl"
{ id(input.substr(start - begin, p - start)); }
break;
case 5:
#line 14 "lel_parser.rl"
#line 15 "lel_parser.rl"
{ row(); }
break;
case 6:
#line 15 "lel_parser.rl"
#line 16 "lel_parser.rl"
{ align((*p)); }
break;
case 7:
#line 16 "lel_parser.rl"
#line 17 "lel_parser.rl"
{ setwidth(std::stoi(tk)); }
break;
case 8:
#line 17 "lel_parser.rl"
#line 18 "lel_parser.rl"
{ setheight(std::stoi(tk)); }
break;
case 9:
#line 18 "lel_parser.rl"
#line 19 "lel_parser.rl"
{ expand(); }
break;
case 10:
#line 26 "lel_parser.rl"
#line 27 "lel_parser.rl"
{ start = p; }
break;
case 11:
#line 29 "lel_parser.rl"
#line 30 "lel_parser.rl"
{start = p;}
break;
#line 216 "lel_parser.cpp"
#line 196 "lel_parser.cpp"
}
}
@ -251,10 +231,14 @@ _again:
_out: {}
}
#line 48 "lel_parser.rl"
#line 49 "lel_parser.rl"
bool good = pe - p == 0;
finalize();
if(good) {
finalize();
} else {
fmt::println("error at");
std::cout << p;
}
return good;
}