[Laszlo-checkins] r13189 - in openlaszlo/branches/4.2: . WEB-INF/lps/server/sc/src/org/openlaszlo/sc WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser WEB-INF/lps/server/src/org/openlaszlo/compiler WEB-INF/lps/server/src/org/openlaszlo/sc
ptw@openlaszlo.org
ptw at openlaszlo.org
Thu Mar 5 12:34:01 PST 2009
Author: ptw
Date: 2009-03-05 12:33:56 -0800 (Thu, 05 Mar 2009)
New Revision: 13189
Added:
openlaszlo/branches/4.2/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/Token.java
Modified:
openlaszlo/branches/4.2/
openlaszlo/branches/4.2/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt
openlaszlo/branches/4.2/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ParseException.java
openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/CompilationError.java
openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/Main.java
openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java
openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java
Log:
Merged revisions 13188 via svnmerge from
http://svn.openlaszlo.org/openlaszlo/trunk
.......
r13188 | dda | 2009-03-05 15:04:44 -0500 (Thu, 05 Mar 2009) | 81 lines
Change 20090303-dda-0 by dda at lester-2.local on 2009-03-03 09:29:19 PST
in /Users/dda/laszlo/src/svn/openlaszlo/trunk-b
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: Capture filename information in parser errors (with addendum 1)
New Features:
Bugs Fixed: LPP-7839: Compiler does not show file name containing the parsing error
Technical Reviewer: ptw (pending)
QA Reviewer: (pending)
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details:
Addendum 1 - changed NodeModel.java and CompilationError.java:
the original changeset caused most errors to no longer show the line numbers.
That was because a workaround the insert the line number was removed because it was no longer needed,
at least for the original test case. This addendum leaves the workaround removed, but file/line information
is now correctly copied from a ParseException to a CompilationError. In NodeModel, we catch
compilation errors for dependencies so they can be displayed normally instead of receiving a stack trace.
WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/Token.java
WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt
WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ParseException.java
WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java
This introduce of a better way to track filenames in the parser.
Javacc does not have a direct way to track filename information for use in error messages, etc.
Since it already keeps line/column information in tokens, it seems sensible to keep that information there, too.
These changes overrides the standard Javacc Token.java with our own version that contains the filename,
and a way to set it from the Parser. It removes the knowledge of the current filename from the
TokenManager.
A ParseException, which only has access to the token, not the tokenmanager, is now equipped to tag
an error message to include the file name.
WEB-INF/lps/server/src/org/openlaszlo/sc/CompilationError.java
When wrapping a ParseException in a CompilationError, correctly copy line number/file name from
one to another.
WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java
When parsing a dependency expression, add the current filename location information.
For compilation errors that happen during creation of dependencies, add the error to the environment,
rather than let a stack trace appear.
WEB-INF/lps/server/src/org/openlaszlo/compiler/Main.java
WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java
Added a 'dumpSourceInput' which is turned on when using -SS that dumps that exact input source
that the script compiler sees into <name>-src-<count>.txt
Tests:
Test case from JIRA now produces a message (not with a stack trace) that includes the filename, and
correct line and column numbers. Works with lzc and in server.
<canvas>
<class name="test" width="1 0"/>
</canvas>
LPP-7839.lzx:2:36: Syntax error: the token "0" was not expected at this position.
Test case with a compilation error not in a dependency also (still) gives a correct error message.
canvas>
<class name="test" width="1"/>
<script>
var z = 422 9;
</script>
</canvas>
LPP-7839b.lzx:4:19: Syntax error: the token "9" was not expected at this position.
Usual regression tests: (smokecheck,weather,lzpix on all platforms).
.......
Property changes on: openlaszlo/branches/4.2
___________________________________________________________________
Name: svnmerge-integrated
- /openlaszlo/branches/4.1:1-10153 /openlaszlo/branches/devildog:1-8432 /openlaszlo/branches/pagan-deities:1-7955,8825,10756-10920,10922-10928,10930-10935,11151,11207,11554 /openlaszlo/branches/paperpie:1-6504,6506-6574,6576-7135,7137-7235 /openlaszlo/branches/wafflecone:1-5746,5818-6068,6070-6205,6207-6213,6216-6265,6267-6368,6370-6431,6433-6450,6497,6509,6661,7097,7872 /openlaszlo/trunk:1-12154,12172-12175,12177-12185,12187-12194,12196,12201,12208,12229,12251-12252,12254-12255,12257-12258,12260,12262-12266,12268-12269,12271-12275,12278-12285,12303,12318-12323,12340-12348,12352,12354-12358,12360-12361,12363,12365-12367,12369-12371,12375-12378,12380-12389,12391,12394-12396,12399-12400,12402-12403,12406-12416,12419-12422,12424-12429,12431-12433,12435,12437-12441,12443,12445,12447,12449-12451,12453-12454,12457-12460,12464,12466-12475,12477-12480,12482-12490,12493-12495,12499-12502,12507-12510,12512,12514-12520,12522,12525-12531,12534-12540,12542,12545,12548-12554,12557-12561,12564,12566-12568,12571,12574-12576,12578,12580,12583-12584,12586-12587,12589,12592-12596,12598-12600,12602-12609,12611-12615,12617,12619-12621,12623,12625,12628-12631,12633-12635,12637,12639,12642,12644,12647-12653,12656,12658,12660,12662-12666,12668-12694,12696,12698-12704,12708-12710,12712-12721,12723-12729,12731-12742,12745-12752,12754-12784,12786-12791,12793-12798,12800-12801,12803,12805-12808,12810-12812,12814,12816-12821,12825-12833,12835-12837,12839-12841,12847,12849-12850,12852-12859,12863-12883,12885-12895,12897-12906,12908-12915,12917-12922,12924-12934,12937-12940,12943-12944,12946-12947,12950-12952,12955-12964,12966-12969,12971,12973-12977,12979-12993,12997-12999,13001-13003,13006-13007,13010-13015,13017-13020,13022-13024,13026-13031,13033,13035-13037,13039-13040,13043,13046-13052,13055-13060,13062-13069,13071-13072,13074,13076-13085,13087-13093,13095-13101,13103-13104,13106,13108-13110,13112,13114-13120,13122,13125-13126,13129,13132-13136,13139-13140,13142,13147,13157-13158,13163,13167,13176,13186
+ /openlaszlo/branches/4.1:1-10153 /openlaszlo/branches/devildog:1-8432 /openlaszlo/branches/pagan-deities:1-7955,8825,10756-10920,10922-10928,10930-10935,11151,11207,11554 /openlaszlo/branches/paperpie:1-6504,6506-6574,6576-7135,7137-7235 /openlaszlo/branches/wafflecone:1-5746,5818-6068,6070-6205,6207-6213,6216-6265,6267-6368,6370-6431,6433-6450,6497,6509,6661,7097,7872 /openlaszlo/trunk:1-12154,12172-12175,12177-12185,12187-12194,12196,12201,12208,12229,12251-12252,12254-12255,12257-12258,12260,12262-12266,12268-12269,12271-12275,12278-12285,12303,12318-12323,12340-12348,12352,12354-12358,12360-12361,12363,12365-12367,12369-12371,12375-12378,12380-12389,12391,12394-12396,12399-12400,12402-12403,12406-12416,12419-12422,12424-12429,12431-12433,12435,12437-12441,12443,12445,12447,12449-12451,12453-12454,12457-12460,12464,12466-12475,12477-12480,12482-12490,12493-12495,12499-12502,12507-12510,12512,12514-12520,12522,12525-12531,12534-12540,12542,12545,12548-12554,12557-12561,12564,12566-12568,12571,12574-12576,12578,12580,12583-12584,12586-12587,12589,12592-12596,12598-12600,12602-12609,12611-12615,12617,12619-12621,12623,12625,12628-12631,12633-12635,12637,12639,12642,12644,12647-12653,12656,12658,12660,12662-12666,12668-12694,12696,12698-12704,12708-12710,12712-12721,12723-12729,12731-12742,12745-12752,12754-12784,12786-12791,12793-12798,12800-12801,12803,12805-12808,12810-12812,12814,12816-12821,12825-12833,12835-12837,12839-12841,12847,12849-12850,12852-12859,12863-12883,12885-12895,12897-12906,12908-12915,12917-12922,12924-12934,12937-12940,12943-12944,12946-12947,12950-12952,12955-12964,12966-12969,12971,12973-12977,12979-12993,12997-12999,13001-13003,13006-13007,13010-13015,13017-13020,13022-13024,13026-13031,13033,13035-13037,13039-13040,13043,13046-13052,13055-13060,13062-13069,13071-13072,13074,13076-13085,13087-13093,13095-13101,13103-13104,13106,13108-13110,13112,13114-13120,13122,13125-13126,13129,13132-13136,13139-13140,13142,13147,13157-13158,13163,13167,13176,13186,13188
Modified: openlaszlo/branches/4.2/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt
===================================================================
--- openlaszlo/branches/4.2/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt 2009-03-05 20:04:44 UTC (rev 13188)
+++ openlaszlo/branches/4.2/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt 2009-03-05 20:33:56 UTC (rev 13189)
@@ -41,7 +41,7 @@
Token t = getToken(1);
if (t!= null) {
SimpleNode sn = (SimpleNode) n;
- sn.setBeginLocation(token_source.pathname,
+ sn.setBeginLocation(t.pathname,
t.beginLine, t.beginColumn);
// See tokenmanager.html in the javacc documentation.
if (t.specialToken != null) {
@@ -97,7 +97,6 @@
TOKEN_MGR_DECLS :
{
- public String pathname;
int beginLine;
}
@@ -111,7 +110,7 @@
<FILENAME> SKIP: {
< (~["\n","\r"])* >
- {pathname = image.toString();} : DEFAULT
+ {Token.setCurrentPathname(image.toString());} : DEFAULT
}
<LINE_NUMBER> SKIP: {
Modified: openlaszlo/branches/4.2/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ParseException.java
===================================================================
--- openlaszlo/branches/4.2/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ParseException.java 2009-03-05 20:04:44 UTC (rev 13188)
+++ openlaszlo/branches/4.2/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ParseException.java 2009-03-05 20:33:56 UTC (rev 13189)
@@ -8,7 +8,7 @@
* ****************************************************************************/
/* J_LZ_COPYRIGHT_BEGIN *******************************************************
-* Copyright 2001-2007 Laszlo Systems, Inc. All Rights Reserved. *
+* Copyright 2001-2009 Laszlo Systems, Inc. All Rights Reserved. *
* Use is subject to license terms. *
* J_LZ_COPYRIGHT_END *********************************************************/
@@ -120,16 +120,14 @@
}
}
- String pathname = null;
-
public String getPathname() {
- return pathname;
+ if (currentToken.next != null) {
+ return currentToken.next.pathname;
+ } else {
+ return null;
+ }
}
- public void initPathname(String pathname) {
- this.pathname = pathname;
- }
-
/**
* This method has the standard behavior when this object has been
* created using the standard constructors. Otherwise, it uses
@@ -143,12 +141,24 @@
public String getMessage() {
return getMessage(true);
}
-
+
+ /**
+ * returns message fragment ' at file XXX, line YYY, column ZZZ'
+ */
+ private String fileLineMessage(Token token) {
+ String retval = " at ";
+ if (token.pathname != null) {
+ retval += "file " + token.pathname + ", ";
+ }
+ retval += "line " + token.beginLine + ", column " + token.beginColumn;
+ return retval;
+ }
+
public String getMessage(boolean includeSourceLocation) {
if (!specialConstructor) {
String retval = super.getMessage();
if (currentToken != null && includeSourceLocation) {
- retval += " at line " + currentToken.beginLine + ", column " + currentToken.beginColumn;
+ retval += fileLineMessage(currentToken);
}
return retval;
}
@@ -202,7 +212,7 @@
}
String retval = "Syntax error: " + msg;
if (currentToken.next != null && includeSourceLocation) {
- retval += " at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
+ retval += fileLineMessage(currentToken.next);
}
retval += ".";
if (expectedCount == 1) {
Copied: openlaszlo/branches/4.2/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/Token.java (from rev 13188, openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/Token.java)
Modified: openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/CompilationError.java
===================================================================
--- openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/CompilationError.java 2009-03-05 20:04:44 UTC (rev 13188)
+++ openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/CompilationError.java 2009-03-05 20:33:56 UTC (rev 13189)
@@ -3,7 +3,7 @@
* ****************************************************************************/
/* J_LZ_COPYRIGHT_BEGIN *******************************************************
-* Copyright 2001-2008 Laszlo Systems, Inc. All Rights Reserved. *
+* Copyright 2001-2009 Laszlo Systems, Inc. All Rights Reserved. *
* Use is subject to license terms. *
* J_LZ_COPYRIGHT_END *********************************************************/
@@ -67,13 +67,13 @@
* @param cause the chained cause of the error
*/
public CompilationError(Element element, Throwable cause) {
- this(getCauseMessage(cause));
+ this(cause);
initElement(element, cause);
}
public CompilationError(Element element, String attribute,
Throwable cause) {
- this(getCauseMessage(cause));
+ this(cause);
initElement(element, attribute, cause);
}
Modified: openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/Main.java
===================================================================
--- openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/Main.java 2009-03-05 20:04:44 UTC (rev 13188)
+++ openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/Main.java 2009-03-05 20:33:56 UTC (rev 13189)
@@ -317,6 +317,7 @@
}
compiler.setProperty(org.openlaszlo.sc.Compiler.DUMP_AST_INPUT, sourceNameNoExt + "-astin-*.txt");
compiler.setProperty(org.openlaszlo.sc.Compiler.DUMP_AST_OUTPUT, sourceNameNoExt + "-astout-*.txt");
+ compiler.setProperty(org.openlaszlo.sc.Compiler.DUMP_SRC_INPUT, sourceNameNoExt + "-src-*.txt");
compiler.setProperty(org.openlaszlo.sc.Compiler.DUMP_LINE_ANNOTATIONS, sourceNameNoExt + "-lineann-*.txt");
}
status += compile(compiler, logger, sourceName, intermediateName, outFileName, outDir);
Modified: openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java
===================================================================
--- openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java 2009-03-05 20:04:44 UTC (rev 13188)
+++ openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java 2009-03-05 20:33:56 UTC (rev 13189)
@@ -21,6 +21,7 @@
import org.openlaszlo.sc.Function;
import org.openlaszlo.sc.Method;
import org.openlaszlo.sc.ScriptCompiler;
+import org.openlaszlo.sc.CompilerException;
import org.openlaszlo.sc.CompilerImplementationError;
import org.openlaszlo.server.*;
import org.openlaszlo.utils.ChainedException;
@@ -296,7 +297,12 @@
return null;
}
String pragmas = "";
- String body = "return (" + getCompiler().dependenciesForExpression(value) + ")";
+ String body = "";
+ try {
+ body = "return (" + getCompiler().dependenciesForExpression(srcloc + value) + ")";
+ } catch (CompilerException e) {
+ env.warn(e, source);
+ }
Function dependencies;
if (canHaveMethods) {
// TODO: [2008-07-21 ptw] (LPP-5813) This should really be
Modified: openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java
===================================================================
--- openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java 2009-03-05 20:04:44 UTC (rev 13188)
+++ openlaszlo/branches/4.2/WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java 2009-03-05 20:33:56 UTC (rev 13189)
@@ -344,6 +344,11 @@
}
cg.setOptions(options);
cg.setOriginalSource(source);
+ String srcDumpFile = (String)options.get(DUMP_SRC_INPUT);
+ if (srcDumpFile != null) {
+ String newname = emitFile(srcDumpFile, source);
+ System.err.println("Created " + newname);
+ }
profiler.enter("parse");
source = cg.preProcess(source);
@@ -471,6 +476,7 @@
public static String DUMP_AST_INPUT = "dumpASTInput";
public static String DUMP_AST_OUTPUT = "dumpASTOutput";
public static String DUMP_LINE_ANNOTATIONS = "dumpLineAnnotations";
+ public static String DUMP_SRC_INPUT = "dumpSourceInput";
public static String DISABLE_CONSTANT_POOL = "disableConstantPool";
public static String DISABLE_TRACK_LINES = "disableTrackLines";
public static String DISABLE_PUBLIC_FOR_DEBUG = "disablePublicForDebug";
@@ -544,16 +550,7 @@
org.openlaszlo.sc.parser.Parser p =
new org.openlaszlo.sc.parser.Parser(new StringReader(str));
assert "Program".equals(type);
- try {
- return p.Program();
- } catch (ParseException pe) {
- // NOTE: [2007-03-27 ptw]
- // The parser tracks #file declarations, but does not pass the
- // file to the exception constructor, so we fix that up here.
- // (This is really a limitation of javacc.)
- pe.initPathname(p.token_source.pathname);
- throw pe;
- }
+ return p.Program();
}
public SimpleNode parse0(String str) {
More information about the Laszlo-checkins
mailing list