Skip to content

Commit

Permalink
Apply a few transformation for the short list output.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmsc committed Jul 27, 2024
1 parent 45d6430 commit 29a6efd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/compiler/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ static bool parse_literal(parse &s, std::string lit)
}
s.debug("GOT '" + lit + "'");
s.add_text(ucase(lit));
// Convert some simple alternatives
if(lit == "EXEc")
lit = "@";
else if(lit == "PRInt")
lit = "?";
else if(lit == "ADR(")
{
lit = "&";
s.expand.remove_parens++;
}

for(auto c: lit)
{
if(c >= 'a' && c <= 'z')
Expand Down
7 changes: 7 additions & 0 deletions src/compiler/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class parse
std::string stext;
int indent = 0;
int next_indent = 0;
int remove_parens = 0;
void clear()
{
text.clear();
Expand All @@ -84,6 +85,7 @@ class parse
{
auto ret = stext;
stext.clear();
remove_parens = 0;
while(ret.size() && ret.back() == ' ')
ret.pop_back();
return ret;
Expand Down Expand Up @@ -457,6 +459,11 @@ class parse
}
void add_s_lit(char c)
{
if(c == ')' && expand.remove_parens)
{
expand.remove_parens--;
return;
}
if((c < 'A' || c > 'Z') && (c < '0' || c > '9') && c != '_')
if(expand.stext.size() && expand.stext.back() == ' ')
expand.stext.resize(expand.stext.size()-1);
Expand Down

0 comments on commit 29a6efd

Please sign in to comment.