Permalink
Browse files

ops, missing an important element on positioned error messages

  • Loading branch information...
porcelli committed May 9, 2012
1 parent f8632b6 commit 482f0d2d0b099de9f26955428e38fcfba0643db7
@@ -18,7 +18,6 @@
import java.util.List;
import org.antlr.runtime.tree.Tree;
-import org.dynjs.exception.DynJSException;
import org.dynjs.parser.statement.ArrayLiteralStatement;
import org.dynjs.parser.statement.AssignmentOperationStatement;
import org.dynjs.parser.statement.BlockStatement;
@@ -129,15 +128,15 @@ public Statement defineFunction(final Tree tree, final String identifier, final
}
public Statement defineShlOp(final Tree tree, Statement l, Statement r) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement defineShrOp(final Tree tree, Statement l, Statement r) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement defineShuOp(final Tree tree, Statement l, Statement r) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement defineDivOp(final Tree tree, Statement l, Statement r) {
@@ -169,15 +168,15 @@ public Statement defineDecOp(final Tree tree, Statement expression) {
}
public Statement definePosOp(final Tree tree, Statement expression) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement defineNegOp(final Tree tree, Statement expression) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement defineInvOp(final Tree tree, Statement expression) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement defineNotOp(final Tree tree, Statement expression) {
@@ -213,7 +212,7 @@ public Statement defineInstanceOfRelOp(final Tree tree, final Statement l, final
}
public Statement defineInRelOp(final Tree tree, Statement l, Statement r) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement defineLorOp(final Tree tree, final Statement l, final Statement r) {
@@ -225,15 +224,15 @@ public Statement defineLandOp(final Tree tree, Statement l, Statement r) {
}
public Statement defineAndBitOp(final Tree tree, Statement l, Statement r) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement defineOrBitOp(final Tree tree, Statement l, Statement r) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement defineXorBitOp(final Tree tree, Statement l, Statement r) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement defineEqOp(final Tree tree, final Statement l, final Statement r) {
@@ -277,43 +276,43 @@ public Statement defineSubAssOp(final Tree tree, Statement l, Statement r) {
}
public Statement defineShlAssOp(final Tree tree, Statement l, Statement r) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement defineShrAssOp(final Tree tree, Statement l, Statement r) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement defineShuAssOp(final Tree tree, Statement l, Statement r) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement defineAndAssOp(final Tree tree, Statement l, Statement r) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement defineXorAssOp(final Tree tree, Statement l, Statement r) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement defineOrAssOp(final Tree tree, Statement l, Statement r) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement defineQueOp(final Tree tree, Statement ex1, Statement ex2, Statement ex3) {
return new IfStatement(tree, context, ex1, ex2, ex3);
}
public Statement defineThisLiteral(final Tree tree) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement defineNullLiteral(final Tree tree) {
return new NullLiteralStatement(tree);
}
public Statement defineRegExLiteral(final Tree tree) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement defineTrueLiteral(final Tree tree) {
@@ -353,23 +352,23 @@ public Statement forStepVar(final Tree tree, final Statement varDef, final State
}
public Statement forStepExpr(final Tree tree, final Statement expr1, final Statement expr2, final Statement expr3, Statement statement) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement forIterVar(final Tree tree, final Statement varDef, final Statement expr1, final Statement statement) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement forIterExpr(final Tree tree, final Statement expr1, final Statement expr2, final Statement statement) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement continueStatement(final Tree tree, String id) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement breakStatement(final Tree tree, String id) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement exprListStatement(final List<Statement> exprList) {
@@ -381,39 +380,39 @@ public Statement resolveCallExpr(final Tree tree, Statement lhs, List<Statement>
}
public Statement switchStatement(final Tree tree, Statement expr, Statement _default, List<Statement> cases) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement switchCaseClause(final Tree tree, Statement expr, List<Statement> statements) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement switchDefaultClause(final Tree tree, List<Statement> statements) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement throwStatement(final Tree tree, final Statement expression) {
return new ThrowStatement(tree);
}
public Statement tryStatement(final Tree tree, Statement block, Statement _catch, Statement _finally) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement tryCatchClause(final Tree tree, String id, Statement block) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement tryFinallyClause(final Tree tree, Statement block) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement withStatement(final Tree tree, Statement expression, Statement statement) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement labelledStatement(final Tree tree, String label, Statement statement) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", tree);
}
public Statement objectValue(final Tree tree, List<Statement> namedValues) {
@@ -429,7 +428,7 @@ public Statement propertyNameString(final Tree tree, final String string) {
}
public Statement propertyNameNumeric(Statement numericLiteral) {
- throw new DynJSException("not implemented yet");
+ throw new ParserException("not implemented yet", numericLiteral.getPosition());
}
public Statement namedValue(final Tree tree, final Statement propertyName, final Statement expr) {
@@ -0,0 +1,39 @@
+/**
+ * Copyright 2012 Douglas Campos, and individual contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.dynjs.parser;
+
+import org.antlr.runtime.tree.Tree;
+import org.dynjs.exception.DynJSException;
+
+public class ParserException extends DynJSException {
+
+ public ParserException() {
+ super();
+ }
+
+ public ParserException(final Exception e) {
+ super(e);
+ }
+
+ public ParserException(final String message, final Tree tree) {
+ this(message, new Position(tree));
+ }
+
+ public ParserException(final String message, final Position position) {
+ super(position.toString() + " " + message);
+ }
+}
@@ -16,6 +16,16 @@
package org.dynjs.parser;
-public interface Position {
+import org.antlr.runtime.tree.Tree;
+public class Position {
+
+ public Position(final Tree tree) {
+
+ }
+
+ @Override
+ public String toString() {
+ return "<>";
+ }
}
@@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.dynjs.exception;
+package org.dynjs.parser;
import org.antlr.runtime.RecognitionException;
-public class SyntaxError extends DynJSException {
+public class SyntaxError extends ParserException {
public SyntaxError(RecognitionException e) {
super(e);
@@ -30,7 +30,7 @@
import org.antlr.runtime.tree.CommonTreeNodeStream;
import org.dynjs.api.Scope;
import org.dynjs.compiler.DynJSCompiler;
-import org.dynjs.exception.SyntaxError;
+import org.dynjs.parser.SyntaxError;
import org.dynjs.parser.ES3Lexer;
import org.dynjs.parser.ES3Parser;
import org.dynjs.parser.ES3Walker;

0 comments on commit 482f0d2

Please sign in to comment.