Mercurial Hosting > luan
changeset 91:1f8b6edc2b08
better error message
git-svn-id: https://luan-java.googlecode.com/svn/trunk@92 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Thu, 07 Mar 2013 22:52:53 +0000 |
parents | b1e87f1bcc13 |
children | d03022acea47 |
files | src/luan/LuanElement.java src/luan/LuanSource.java src/luan/LuanState.java src/luan/interp/LuanCompiler.java src/luan/lib/PackageLib.java |
diffstat | 5 files changed, 20 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
diff -r b1e87f1bcc13 -r 1f8b6edc2b08 src/luan/LuanElement.java --- a/src/luan/LuanElement.java Sat Mar 02 05:02:56 2013 +0000 +++ b/src/luan/LuanElement.java Thu Mar 07 22:52:53 2013 +0000 @@ -14,10 +14,4 @@ return "Java"; } }; - - public static final LuanElement COMPILER = new LuanElement(){ - @Override String location() { - return "Compiler"; - } - }; }
diff -r b1e87f1bcc13 -r 1f8b6edc2b08 src/luan/LuanSource.java --- a/src/luan/LuanSource.java Sat Mar 02 05:02:56 2013 +0000 +++ b/src/luan/LuanSource.java Thu Mar 07 22:52:53 2013 +0000 @@ -10,6 +10,20 @@ this.text = text; } + public static final class CompilerElement extends LuanElement { + public final LuanSource source; + + public CompilerElement(LuanSource source) { + if( source==null ) + throw new NullPointerException("source is null"); + this.source = source; + } + + @Override String location() { + return "Compiling " + source.name; + } + } + public static final class Element extends LuanElement { public final LuanSource source; public final int start;
diff -r b1e87f1bcc13 -r 1f8b6edc2b08 src/luan/LuanState.java --- a/src/luan/LuanState.java Sat Mar 02 05:02:56 2013 +0000 +++ b/src/luan/LuanState.java Thu Mar 07 22:52:53 2013 +0000 @@ -20,7 +20,6 @@ public static final String _G = "_G"; public final LuanBit JAVA = bit(LuanElement.JAVA); - public final LuanBit COMPILER = bit(LuanElement.COMPILER); private LuanTable loaded; private LuanTable preload;
diff -r b1e87f1bcc13 -r 1f8b6edc2b08 src/luan/interp/LuanCompiler.java --- a/src/luan/interp/LuanCompiler.java Sat Mar 02 05:02:56 2013 +0000 +++ b/src/luan/interp/LuanCompiler.java Thu Mar 07 22:52:53 2013 +0000 @@ -21,8 +21,11 @@ LuanParser parser = Parboiled.createParser(LuanParser.class,src,envGetter); ParsingResult<?> result = new ReportingParseRunner(parser.Target()).run(src.text); // ParsingResult<?> result = new TracingParseRunner(parser.Target()).run(src); - if( result.hasErrors() ) - throw luan.COMPILER.exception( ErrorUtils.printParseErrors(result) ); + if( result.hasErrors() ) { +// throw luan.COMPILER.exception( ErrorUtils.printParseErrors(result) ); + LuanElement le = new LuanSource.CompilerElement(src); + throw luan.bit(le).exception( ErrorUtils.printParseErrors(result) ); + } FnDef fnDef = (FnDef)result.resultValue; return new Closure((LuanStateImpl)luan,fnDef); }
diff -r b1e87f1bcc13 -r 1f8b6edc2b08 src/luan/lib/PackageLib.java --- a/src/luan/lib/PackageLib.java Sat Mar 02 05:02:56 2013 +0000 +++ b/src/luan/lib/PackageLib.java Thu Mar 07 22:52:53 2013 +0000 @@ -64,7 +64,7 @@ Object[] a = luan.JAVA.call(searcher,"<searcher>",modName); if( a.length >= 1 && a[0] instanceof LuanFunction ) { LuanFunction loader = (LuanFunction)a[0]; - luan.JAVA.call(loader,"<loader>"); + luan.JAVA.call(loader,"<require \""+modName+"\">"); mod = (LuanTable)luan.loaded().get(modName); if( mod==null ) throw luan.JAVA.exception( "module '"+modName+"' didn't define its module" );