diff --git a/Z3Experiments/Z3Experiments/Parser/PreposeParserException.cs b/Z3Experiments/Z3Experiments/Parser/PreposeParserException.cs
new file mode 100644
index 0000000..138dc5f
--- /dev/null
+++ b/Z3Experiments/Z3Experiments/Parser/PreposeParserException.cs
@@ -0,0 +1,48 @@
+using Antlr4.Runtime;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PreposeGestures
+{
+ public class PreposeParserException : Exception
+ {
+ private readonly int startLineNumber;
+ private readonly int startColumnNumber;
+
+ private readonly int endLineNumber;
+ private readonly int endColumnNumber;
+
+ public int StartLineNumber
+ {
+ get { return this.startLineNumber; }
+ }
+
+ public int StartColumnNumber
+ {
+ get { return this.startColumnNumber; }
+ }
+
+ public int EndLineNumber
+ {
+ get { return this.endLineNumber; }
+ }
+
+ public int EndColumnNumber
+ {
+ get { return this.endColumnNumber; }
+ }
+
+ public PreposeParserException(string message, ParserRuleContext currentContext)
+ : base(message)
+ {
+ this.startLineNumber = currentContext.start.Line;
+ this.startColumnNumber = currentContext.start.Column;
+
+ this.endLineNumber = currentContext.stop.Line;
+ this.endColumnNumber = currentContext.stop.Column;
+ }
+ }
+}
diff --git a/Z3Experiments/Z3Experiments/Parser/Visitor.cs b/Z3Experiments/Z3Experiments/Parser/Visitor.cs
index 142ec35..ba95bff 100644
--- a/Z3Experiments/Z3Experiments/Parser/Visitor.cs
+++ b/Z3Experiments/Z3Experiments/Parser/Visitor.cs
@@ -155,7 +155,10 @@ namespace PreposeGestures.Parser
{
Contract.Assert(s != null);
var w = this.Visit(s);
- Contract.Assert(w != null);
+ if (w == null)
+ {
+ throw new PreposeParserException("Failed to parse statement", s);
+ }
var statement = w.GetValue();
if (statement != null)
{
@@ -171,14 +174,14 @@ namespace PreposeGestures.Parser
continue;
}
- throw new ArgumentException("Wrong return type");
+ throw new PreposeParserException("Invalid return type", s);
}
}
var pose = new Pose(context.ID().GetText(), bt, br);
if (this.Poses.ContainsKey(pose.Name))
{
- throw new ArgumentException("Pose " + pose.Name + " has been previosly seen.");
+ throw new PreposeParserException("Pose " + pose.Name + " has been previously seen.", context);
}
this.Poses.Add(pose.Name, pose);
diff --git a/Z3Experiments/Z3Experiments/PreposeGestures.csproj b/Z3Experiments/Z3Experiments/PreposeGestures.csproj
index c8f8e90..9b5624e 100644
--- a/Z3Experiments/Z3Experiments/PreposeGestures.csproj
+++ b/Z3Experiments/Z3Experiments/PreposeGestures.csproj
@@ -117,6 +117,7 @@
+