From 29a6efdfa620ebaf9891331a4e18ffacf86a245d Mon Sep 17 00:00:00 2001 From: Daniel Serpell Date: Sat, 27 Jul 2024 17:54:41 -0400 Subject: [PATCH] Apply a few transformation for the short list output. --- src/compiler/parser.cc | 11 +++++++++++ src/compiler/parser.h | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/src/compiler/parser.cc b/src/compiler/parser.cc index 6d38c28..11fb54f 100644 --- a/src/compiler/parser.cc +++ b/src/compiler/parser.cc @@ -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') diff --git a/src/compiler/parser.h b/src/compiler/parser.h index 5913bb4..5417409 100644 --- a/src/compiler/parser.h +++ b/src/compiler/parser.h @@ -65,6 +65,7 @@ class parse std::string stext; int indent = 0; int next_indent = 0; + int remove_parens = 0; void clear() { text.clear(); @@ -84,6 +85,7 @@ class parse { auto ret = stext; stext.clear(); + remove_parens = 0; while(ret.size() && ret.back() == ' ') ret.pop_back(); return ret; @@ -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);