I think math is stable now

I need to rewrite how math is done to allow for the introduction of constructs
This commit is contained in:
Ryan 2017-08-22 22:34:16 -04:00
parent 74324b86c3
commit 6123423f78
2 changed files with 10 additions and 8 deletions

View File

@ -6,9 +6,8 @@ ENABLE leaking
[START]{
"Test 1:"
t=15
test=2+t
test=2*100
"test = $test$"
"num = $num$"
c=5
::HERE::
a,b="sdf",true
@ -16,6 +15,9 @@ ENABLE leaking
food="yum"
test=true
stop=21
"food = $food$"
"test = $test$"
"stop = $stop$"
"Test 2:"
count=0
::loop::

View File

@ -428,7 +428,7 @@ namespace parseManager
tCont = Regex.Replace(tCont, @"\-\-\[\[[\S\s]+\]\]", "", RegexOptions.Multiline);
tCont = Regex.Replace(tCont, @"^\s+$[\r\n]*", "", RegexOptions.Multiline);
_lines = tCont.Split(new [] { "\r\n", "\n" }, StringSplitOptions.None);
compile(); // compiles the code into something that can be used quickly
compile();
}
void compile()
{
@ -436,10 +436,13 @@ namespace parseManager
for (int i = 0; i < _lines.Length - 1; i++) {
temp = _lines[i];
var pureLine = Regex.Match(temp, "^\"(.+)\"");
var FuncTest = Regex.Match(temp, @"([a-zA-Z0-9_]+)\s?\((.*)\)");
var assignment = Regex.Match(temp, "^([a-zA-Z0-9_,\\[\\]\"]+)=([a-zA-Z\\|&\\^\\+\\-\\*/%0-9_\",\\[\\]]+)");
if (assignment.ToString() != "") { // TODO fix mess! or write own number calculator
if (assignment.ToString() != "" && FuncTest.ToString()=="") { // TODO fix mess! or write own number calculator
var expression = new Expression(assignment.Groups[2].Value);
if (!expression.HasErrors()) {
var extest = assignment.Groups[2].Value;
var res = Regex.Match(extest,@"[\+\-\*/%\^]");
if (!expression.HasErrors() && res.ToString()!="") {
temp=assignment.Groups[1].Value+"=CALC(\""+assignment.Groups[2]+"\")";
}
}
@ -457,11 +460,9 @@ namespace parseManager
string _funcif = (argsif.Groups[1]).ToString();
var _argsif = (argsif.Groups[2]).ToString();
string[] _resultif = Regex.Split(_argsif, ",(?=(?:[^\"']*[\"'][^\"']*[\"'])*[^\"']*$)");
//Console.WriteLine(string.Join(",",_resultif));
string _funcelse = (argselse.Groups[1]).ToString();
var _argselse = (argselse.Groups[2]).ToString();
string[] _resultelse = Regex.Split(_argselse, ",(?=(?:[^\"']*[\"'][^\"']*[\"'])*[^\"']*$)");
//Console.WriteLine(string.Join(",",_resultelse));
var mm = Regex.Matches(condition, "(.+?)([and ]+?[or ]+)");
var conds = new string[(mm.Count + 1) * 3];
var andors = new string[mm.Count];
@ -485,7 +486,6 @@ namespace parseManager
var s1a2 = s1p2.Groups[1].ToString();
var s1b2 = s1p2.Groups[2].ToString();
var s1c2 = s1p2.Groups[3].ToString();
//Console.WriteLine(s1a2+"|"+s1b2+"|"+s1c2);
conds[p++] = s1a2;
conds[p++] = s1b2;
conds[p++] = s1c2;