You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by sy...@apache.org on 2015/01/31 23:19:45 UTC

[1/2] lucenenet git commit: Expressions: better error message on parse errors

Repository: lucenenet
Updated Branches:
  refs/heads/master 2c566585c -> d463487cc


Expressions: better error message on parse errors

Seems like the Antlr definition used or its compilation is faulty, currently all scripts with numerics are failing


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/2fcf7d2b
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/2fcf7d2b
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/2fcf7d2b

Branch: refs/heads/master
Commit: 2fcf7d2b34b22a24a5c1bbb080851f6631af971a
Parents: 2c56658
Author: Itamar Syn-Hershko <it...@code972.com>
Authored: Sun Feb 1 00:19:05 2015 +0200
Committer: Itamar Syn-Hershko <it...@code972.com>
Committed: Sun Feb 1 00:19:05 2015 +0200

----------------------------------------------------------------------
 src/Lucene.Net.Expressions/JS/JavascriptLexer.cs | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2fcf7d2b/src/Lucene.Net.Expressions/JS/JavascriptLexer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Expressions/JS/JavascriptLexer.cs b/src/Lucene.Net.Expressions/JS/JavascriptLexer.cs
index 90c770e..80b8128 100644
--- a/src/Lucene.Net.Expressions/JS/JavascriptLexer.cs
+++ b/src/Lucene.Net.Expressions/JS/JavascriptLexer.cs
@@ -90,10 +90,9 @@ namespace Lucene.Net.Expressions.JS
 		// ANTLR GENERATED CODE: DO NOT EDIT
 		public override void DisplayRecognitionError(string[] tokenNames, RecognitionException re)
 		{
-			string message = " unexpected character '" + (char)re.Character + "' at position (" + re.CharPositionInLine + ").";
-			ParseException parseException = new ParseException(message, re.CharPositionInLine);
-			
-			throw new SystemException(parseException.Message, parseException);
+            var message = string.Format("Unable to parse '{0}': unexpected character '{1}' at position ({2}).", re.Input
+                , (char)re.Character, re.CharPositionInLine);
+			throw new ParseException(message, re.CharPositionInLine);
 		}
 
 		// delegates
@@ -2169,9 +2168,11 @@ loop16_break: ;
 
     public class ParseException:Exception
     {
-        public ParseException(string message, int charPositionInLine)
+        private readonly int _charPositionInLine;
+
+        public ParseException(string message, int charPositionInLine) : base(message)
         {
-            
+            _charPositionInLine = charPositionInLine;
         }
     }
 }


Re: [1/2] lucenenet git commit: Expressions: better error message on parse errors

Posted by Hakeem Mohammed <ha...@gmail.com>.
Ya, they were failing bcoz of the differences between how Java handles
strings with numerals and the C# impl. I do have them working now. will
open a PR later tonight. Thx

On Sat, Jan 31, 2015 at 5:22 PM, Itamar Syn-Hershko <it...@code972.com>
wrote:

> Hakeem - can you please take a look?
>
> Something in the Antlr code generation didn't work as planned (assuming you
> didn't just port the code from the Java version)
>
> --
>
> Itamar Syn-Hershko
> http://code972.com | @synhershko <https://twitter.com/synhershko>
> Freelance Developer & Consultant
> Lucene.NET committer and PMC member
>
> On Sun, Feb 1, 2015 at 12:19 AM, <sy...@apache.org> wrote:
>
> > Repository: lucenenet
> > Updated Branches:
> >   refs/heads/master 2c566585c -> d463487cc
> >
> >
> > Expressions: better error message on parse errors
> >
> > Seems like the Antlr definition used or its compilation is faulty,
> > currently all scripts with numerics are failing
> >
> >
> > Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
> > Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/2fcf7d2b
> > Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/2fcf7d2b
> > Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/2fcf7d2b
> >
> > Branch: refs/heads/master
> > Commit: 2fcf7d2b34b22a24a5c1bbb080851f6631af971a
> > Parents: 2c56658
> > Author: Itamar Syn-Hershko <it...@code972.com>
> > Authored: Sun Feb 1 00:19:05 2015 +0200
> > Committer: Itamar Syn-Hershko <it...@code972.com>
> > Committed: Sun Feb 1 00:19:05 2015 +0200
> >
> > ----------------------------------------------------------------------
> >  src/Lucene.Net.Expressions/JS/JavascriptLexer.cs | 13 +++++++------
> >  1 file changed, 7 insertions(+), 6 deletions(-)
> > ----------------------------------------------------------------------
> >
> >
> >
> >
> http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2fcf7d2b/src/Lucene.Net.Expressions/JS/JavascriptLexer.cs
> > ----------------------------------------------------------------------
> > diff --git a/src/Lucene.Net.Expressions/JS/JavascriptLexer.cs
> > b/src/Lucene.Net.Expressions/JS/JavascriptLexer.cs
> > index 90c770e..80b8128 100644
> > --- a/src/Lucene.Net.Expressions/JS/JavascriptLexer.cs
> > +++ b/src/Lucene.Net.Expressions/JS/JavascriptLexer.cs
> > @@ -90,10 +90,9 @@ namespace Lucene.Net.Expressions.JS
> >                 // ANTLR GENERATED CODE: DO NOT EDIT
> >                 public override void DisplayRecognitionError(string[]
> > tokenNames, RecognitionException re)
> >                 {
> > -                       string message = " unexpected character '" +
> > (char)re.Character + "' at position (" + re.CharPositionInLine + ").";
> > -                       ParseException parseException = new
> > ParseException(message, re.CharPositionInLine);
> > -
> > -                       throw new SystemException(parseException.Message,
> > parseException);
> > +            var message = string.Format("Unable to parse '{0}':
> > unexpected character '{1}' at position ({2}).", re.Input
> > +                , (char)re.Character, re.CharPositionInLine);
> > +                       throw new ParseException(message,
> > re.CharPositionInLine);
> >                 }
> >
> >                 // delegates
> > @@ -2169,9 +2168,11 @@ loop16_break: ;
> >
> >      public class ParseException:Exception
> >      {
> > -        public ParseException(string message, int charPositionInLine)
> > +        private readonly int _charPositionInLine;
> > +
> > +        public ParseException(string message, int charPositionInLine) :
> > base(message)
> >          {
> > -
> > +            _charPositionInLine = charPositionInLine;
> >          }
> >      }
> >  }
> >
> >
>

Re: [1/2] lucenenet git commit: Expressions: better error message on parse errors

Posted by Itamar Syn-Hershko <it...@code972.com>.
Hakeem - can you please take a look?

Something in the Antlr code generation didn't work as planned (assuming you
didn't just port the code from the Java version)

--

Itamar Syn-Hershko
http://code972.com | @synhershko <https://twitter.com/synhershko>
Freelance Developer & Consultant
Lucene.NET committer and PMC member

On Sun, Feb 1, 2015 at 12:19 AM, <sy...@apache.org> wrote:

> Repository: lucenenet
> Updated Branches:
>   refs/heads/master 2c566585c -> d463487cc
>
>
> Expressions: better error message on parse errors
>
> Seems like the Antlr definition used or its compilation is faulty,
> currently all scripts with numerics are failing
>
>
> Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
> Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/2fcf7d2b
> Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/2fcf7d2b
> Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/2fcf7d2b
>
> Branch: refs/heads/master
> Commit: 2fcf7d2b34b22a24a5c1bbb080851f6631af971a
> Parents: 2c56658
> Author: Itamar Syn-Hershko <it...@code972.com>
> Authored: Sun Feb 1 00:19:05 2015 +0200
> Committer: Itamar Syn-Hershko <it...@code972.com>
> Committed: Sun Feb 1 00:19:05 2015 +0200
>
> ----------------------------------------------------------------------
>  src/Lucene.Net.Expressions/JS/JavascriptLexer.cs | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> ----------------------------------------------------------------------
>
>
>
> http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2fcf7d2b/src/Lucene.Net.Expressions/JS/JavascriptLexer.cs
> ----------------------------------------------------------------------
> diff --git a/src/Lucene.Net.Expressions/JS/JavascriptLexer.cs
> b/src/Lucene.Net.Expressions/JS/JavascriptLexer.cs
> index 90c770e..80b8128 100644
> --- a/src/Lucene.Net.Expressions/JS/JavascriptLexer.cs
> +++ b/src/Lucene.Net.Expressions/JS/JavascriptLexer.cs
> @@ -90,10 +90,9 @@ namespace Lucene.Net.Expressions.JS
>                 // ANTLR GENERATED CODE: DO NOT EDIT
>                 public override void DisplayRecognitionError(string[]
> tokenNames, RecognitionException re)
>                 {
> -                       string message = " unexpected character '" +
> (char)re.Character + "' at position (" + re.CharPositionInLine + ").";
> -                       ParseException parseException = new
> ParseException(message, re.CharPositionInLine);
> -
> -                       throw new SystemException(parseException.Message,
> parseException);
> +            var message = string.Format("Unable to parse '{0}':
> unexpected character '{1}' at position ({2}).", re.Input
> +                , (char)re.Character, re.CharPositionInLine);
> +                       throw new ParseException(message,
> re.CharPositionInLine);
>                 }
>
>                 // delegates
> @@ -2169,9 +2168,11 @@ loop16_break: ;
>
>      public class ParseException:Exception
>      {
> -        public ParseException(string message, int charPositionInLine)
> +        private readonly int _charPositionInLine;
> +
> +        public ParseException(string message, int charPositionInLine) :
> base(message)
>          {
> -
> +            _charPositionInLine = charPositionInLine;
>          }
>      }
>  }
>
>

[2/2] lucenenet git commit: Fix a KeyNotFound exception

Posted by sy...@apache.org.
Fix a KeyNotFound exception


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/d463487c
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/d463487c
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/d463487c

Branch: refs/heads/master
Commit: d463487ccec393fdfae491a85a76e293fc6d2b7d
Parents: 2fcf7d2
Author: Itamar Syn-Hershko <it...@code972.com>
Authored: Sun Feb 1 00:19:24 2015 +0200
Committer: Itamar Syn-Hershko <it...@code972.com>
Committed: Sun Feb 1 00:19:24 2015 +0200

----------------------------------------------------------------------
 src/Lucene.Net.Expressions/SimpleBindings.cs | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d463487c/src/Lucene.Net.Expressions/SimpleBindings.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Expressions/SimpleBindings.cs b/src/Lucene.Net.Expressions/SimpleBindings.cs
index f317970..92dfc9f 100644
--- a/src/Lucene.Net.Expressions/SimpleBindings.cs
+++ b/src/Lucene.Net.Expressions/SimpleBindings.cs
@@ -59,16 +59,18 @@ namespace Lucene.Net.Expressions
 
 		public override ValueSource GetValueSource(string name)
 		{
-		    object o = map[name];
-			if (o == null)
+		    object o;
+			if (!map.TryGetValue(name, out o))
 			{
 				throw new ArgumentException("Invalid reference '" + name + "'");
 			}
+
 		    var expression = o as Expression;
 		    if (expression != null)
 		    {
 		        return expression.GetValueSource(this);
 		    }
+
 		    SortField field = (SortField)o;
 			switch (field.Type)
 			{