From ee3c5ebb29439a169fbfe1cc1aa2a7d4c1fbf28d Mon Sep 17 00:00:00 2001 From: Robert Plummer Date: Mon, 9 Sep 2013 08:55:17 -0400 Subject: [PATCH] Change a few options to get c# partially working --- Formula.cs | 24 ++++++++++-------------- formula.jison | 9 ++++++--- formula.js | 6 ++++-- formula.php | 10 +++------- 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/Formula.cs b/Formula.cs index b600545..0a5d8c2 100644 --- a/Formula.cs +++ b/Formula.cs @@ -2,7 +2,7 @@ using System.Text.RegularExpressions; using System.Collections.Generic; using System.Linq; - +using Sheet; namespace Jison { @@ -1873,7 +1873,7 @@ public Formula() } - public Sheet.Expression ParserPerformAction(ref Sheet.Expression thisS, ref Sheet.Expression yy, ref int yystate, ref JList ss) + public Expression ParserPerformAction(ref Expression thisS, ref Expression yy, ref int yystate, ref JList ss) { var so = ss.Count - 1; /* this == yyval */ @@ -1973,8 +1973,6 @@ public Sheet.Expression ParserPerformAction(ref Sheet.Expression thisS, ref Shee break; case 13: - thisS = (ss[so-3]) != (ss[so]); - ss[so-3].Set(ss[so-3].Text != ss[so].Text); thisS = ss[so-3]; @@ -1982,8 +1980,6 @@ public Sheet.Expression ParserPerformAction(ref Sheet.Expression thisS, ref Shee break; case 14: - thisS = ss[so-2] != ss[so]; - ss[so-2].Set(ss[so-2].Text != ss[so].Text); thisS = ss[so-2]; @@ -2240,7 +2236,7 @@ public void LexerError(string error, LexerError hash = null) throw new InvalidOperationException(error); } - public Sheet.Expression Parse(string input) + public Expression Parse(string input) { if (Table == null) { throw new Exception("Empty table"); @@ -2249,13 +2245,13 @@ public Sheet.Expression Parse(string input) { new ParserCachedAction(new ParserAction(0, Table[0])) }; - var vstack = new JList + var vstack = new JList { - new Sheet.Expression() + new Expression() }; - var yy = new Sheet.Expression(); - var _yy = new Sheet.Expression(); - var v = new Sheet.Expression(); + var yy = new Expression(); + var _yy = new Expression(); + var v = new Expression(); int recovering = 0; ParserSymbol symbol = null; ParserAction action = null; @@ -2369,7 +2365,7 @@ public Sheet.Expression Parse(string input) if (_yy == null) { - vstack.Push(new Sheet.Expression()); + vstack.Push(new Expression()); } else { @@ -2393,7 +2389,7 @@ public Sheet.Expression Parse(string input) /* Jison generated lexer */ public ParserSymbol Eof = new ParserSymbol("Eof", 1); - public Sheet.Expression Yy = new Sheet.Expression(); + public Expression Yy = new Expression(); public string Match = ""; public string Matched = ""; public Stack ConditionStack; diff --git a/formula.jison b/formula.jison index 182f37a..742f5f9 100755 --- a/formula.jison +++ b/formula.jison @@ -1,5 +1,6 @@ //option class:Formula -//option parserValue:Sheet.Expression +//option parserValue:Expression +//option using:Sheet /* description: Parses end evaluates mathematical expressions. */ /* lexical grammar */ %lex @@ -240,7 +241,8 @@ expression */ } | expression '<' '>' expression { - $$ = ($1) != ($4); + //js|php + $$ = ($1) != ($4); //js if (isNaN($$)) { @@ -253,7 +255,8 @@ expression */ } | expression NOT expression { - $$ = $1 != $3; + //js|php + $$ = $1 != $3; /*cs $1.Set($1.Text != $3.Text); diff --git a/formula.js b/formula.js index 0314d2f..64014a0 100644 --- a/formula.js +++ b/formula.js @@ -227,7 +227,8 @@ case 12: break; case 13: - this.$ = ($$[$0-3]) != ($$[$0]); + //js|php + this.$ = ($$[$0-3]) != ($$[$0]); //js if (isNaN(this.$)) { @@ -241,7 +242,8 @@ case 13: break; case 14: - this.$ = $$[$0-2] != $$[$0]; + //js|php + this.$ = $$[$0-2] != $$[$0]; /*cs $$[$0-2].Set($$[$0-2].Text != $$[$0].Text); diff --git a/formula.php b/formula.php index 0a54b3d..25c4d58 100644 --- a/formula.php +++ b/formula.php @@ -6,7 +6,7 @@ -class formula +class Formula { public $symbols = array(); public $terminals = array(); @@ -1997,14 +1997,10 @@ function parserPerformAction(&$thisS, &$yy, $yystate, &$s, $o) break; case 13: - $thisS = ($s[$o-3]) != ($s[$o]); - break; case 14: - $thisS = $s[$o-2] != $s[$o]; - break; @@ -2348,7 +2344,7 @@ function parse($input) if (is_null($_yy)) { - $vstack[] = new ParserValue(); + $vstack[] = new Expression(); } else { @@ -2398,7 +2394,7 @@ function setInput($input) { $this->input = $input; $this->more = $this->less = $this->done = false; - $this->yy = new ParserValue(); + $this->yy = new Expression(); $this->conditionStack = array('INITIAL'); $this->conditionStackCount = 1;