Skip to content

Commit

Permalink
Fixed large amounts of stupid errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Chadderbox committed Dec 27, 2021
1 parent 8792dc9 commit ea2b98a
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions parse.cb
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,6 @@ class Parser

function ParseKeyWords(code: str) is str
{
for line in code.splitlines()
{
if "this" in line
{
if not this.IsInString("this", line)
{
code = code.replace(line, line.replace("this", "self"));
}
}
}
for line in code.splitlines()
{
if "true" in line
Expand Down Expand Up @@ -458,6 +448,24 @@ class Parser
{
//I'm not going to lie, I made a lot of mistakes. Let's hope these hacks fix it.

newCode = "";
for line in code.splitlines()
{
chars = "";
for c in line
{
if "t"+"his" in line
{
if not this.IsInString(("t"+"his"), line)
{
line = line.replace(("t"+"his"), "self");
}
}
}
newCode += line + "\n";
}
code = newCode;

splitLines = code.splitlines();
for lineNo, line in enumerate(splitLines)
{
Expand Down Expand Up @@ -506,18 +514,6 @@ class Parser
}
code = newCode;

//this
for line in code.splitlines()
{
if "this" in line
{
if not this.IsInString("this", line)
{
code = code.replace(line, line.replace("this", "self"));
}
}
}

//Remove indent helpers
newCode = "";
for line in code.splitlines()
Expand Down Expand Up @@ -569,16 +565,17 @@ class Parser
return code;
}

function IsInString(phrase : str, line : str, returnIfMultiple = false) is bool
function IsInString(phrase : str, line : str, returnIfMultiple = false, returnIfNotInLine = false) is bool
{
if not phrase in line
{
return false;
return returnIfNotInLine;
}
if line.count(phrase) > 1
{
return returnIfMultiple;
}

leftSide = line.partition(phrase)[0];
if leftSide.count("\"") > 0
{
Expand All @@ -591,6 +588,7 @@ class Parser
return true;
}
}

if leftSide.count("\'") > 0
{
if leftSide.count("\'") % 2 == 0
Expand Down

0 comments on commit ea2b98a

Please sign in to comment.