diff --git a/compiler/frontend/buildLexer.xml b/compiler/frontend/buildLexer.xml
index 0452dbdb961..0bd2753409e 100644
--- a/compiler/frontend/buildLexer.xml
+++ b/compiler/frontend/buildLexer.xml
@@ -36,6 +36,12 @@
+
+
+
+
diff --git a/compiler/frontend/src/org/jetbrains/jet/kdoc/lexer/_KDocLexer.java b/compiler/frontend/src/org/jetbrains/jet/kdoc/lexer/_KDocLexer.java
index 3d8838b5fda..b5b9825fe3f 100644
--- a/compiler/frontend/src/org/jetbrains/jet/kdoc/lexer/_KDocLexer.java
+++ b/compiler/frontend/src/org/jetbrains/jet/kdoc/lexer/_KDocLexer.java
@@ -1,4 +1,4 @@
-/* The following code was generated by JFlex 1.4.3 on 3/6/14 2:29 PM */
+/* The following code was generated by JFlex 1.4.3 on 5/27/14 6:17 PM */
package org.jetbrains.jet.kdoc.lexer;
@@ -12,7 +12,7 @@ import java.lang.Character;
/**
* This class is a scanner generated by
* JFlex 1.4.3
- * on 3/6/14 2:29 PM from the specification file
+ * on 5/27/14 6:17 PM from the specification file
* /Users/abreslav/work/kotlin/compiler/frontend/src/org/jetbrains/jet/kdoc/lexer/KDoc.flex
*/
class _KDocLexer implements FlexLexer {
diff --git a/compiler/frontend/src/org/jetbrains/jet/lexer/Jet.flex b/compiler/frontend/src/org/jetbrains/jet/lexer/Jet.flex
index 4cc502324e2..2511ef10ee4 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lexer/Jet.flex
+++ b/compiler/frontend/src/org/jetbrains/jet/lexer/Jet.flex
@@ -5,6 +5,7 @@ import com.intellij.lexer.*;
import com.intellij.psi.*;
import com.intellij.psi.tree.IElementType;
import com.intellij.util.containers.Stack;
+import org.jetbrains.jet.lexer.KotlinLexerException;
import org.jetbrains.jet.lexer.JetTokens;
@@ -60,6 +61,8 @@ import org.jetbrains.jet.lexer.JetTokens;
}
%}
+%scanerror KotlinLexerException
+
%function advance
%type IElementType
%eof{
diff --git a/compiler/frontend/src/org/jetbrains/jet/lexer/KotlinLexerException.java b/compiler/frontend/src/org/jetbrains/jet/lexer/KotlinLexerException.java
new file mode 100644
index 00000000000..6162b7340bd
--- /dev/null
+++ b/compiler/frontend/src/org/jetbrains/jet/lexer/KotlinLexerException.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2010-2014 JetBrains s.r.o.
+ *
+ * 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.jetbrains.jet.lexer;
+
+public class KotlinLexerException extends RuntimeException {
+ public KotlinLexerException(String message) {
+ super(message);
+ }
+}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lexer/_JetLexer.java b/compiler/frontend/src/org/jetbrains/jet/lexer/_JetLexer.java
index 87cccb3c944..29f55acd34a 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lexer/_JetLexer.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lexer/_JetLexer.java
@@ -1,4 +1,4 @@
-/* The following code was generated by JFlex 1.4.3 on 5/14/14 2:02 PM */
+/* The following code was generated by JFlex 1.4.3 on 5/27/14 6:17 PM */
package org.jetbrains.jet.lexer;
@@ -7,6 +7,7 @@ import com.intellij.lexer.*;
import com.intellij.psi.*;
import com.intellij.psi.tree.IElementType;
import com.intellij.util.containers.Stack;
+import org.jetbrains.jet.lexer.KotlinLexerException;
import org.jetbrains.jet.lexer.JetTokens;
@@ -14,8 +15,8 @@ import org.jetbrains.jet.lexer.JetTokens;
/**
* This class is a scanner generated by
* JFlex 1.4.3
- * on 5/14/14 2:02 PM from the specification file
- * /Users/svtk/Kotlin/kotlin/compiler/frontend/src/org/jetbrains/jet/lexer/Jet.flex
+ * on 5/27/14 6:17 PM from the specification file
+ * /Users/abreslav/work/kotlin/compiler/frontend/src/org/jetbrains/jet/lexer/Jet.flex
*/
class _JetLexer implements FlexLexer {
/** initial size of the lookahead buffer */
@@ -769,7 +770,7 @@ class _JetLexer implements FlexLexer {
*
* @param errorCode the code of the errormessage to display
*/
- private void zzScanError(int errorCode) {
+ private void zzScanError(int errorCode) throws KotlinLexerException {
String message;
try {
message = ZZ_ERROR_MSG[errorCode];
@@ -778,7 +779,7 @@ class _JetLexer implements FlexLexer {
message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
}
- throw new Error(message);
+ throw new KotlinLexerException(message + "\n at '" + yytext() + "'\n" + zzBuffer);
}
@@ -790,7 +791,7 @@ class _JetLexer implements FlexLexer {
* @param number the number of characters to be read again.
* This number must not be greater than yylength()!
*/
- public void yypushback(int number) {
+ public void yypushback(int number) throws KotlinLexerException {
if ( number > yylength() )
zzScanError(ZZ_PUSHBACK_2BIG);
@@ -818,7 +819,7 @@ class _JetLexer implements FlexLexer {
* @return the next token
* @exception java.io.IOException if any I/O-Error occurs
*/
- public IElementType advance() throws java.io.IOException {
+ public IElementType advance() throws java.io.IOException, KotlinLexerException {
int zzInput;
int zzAction;