[Laszlo-checkins] r10771 - in openlaszlo/trunk/WEB-INF/lps/server: sc/src/org/openlaszlo/sc sc/src/org/openlaszlo/sc/parser src/org/openlaszlo/sc
dda@openlaszlo.org
dda at openlaszlo.org
Mon Aug 25 14:45:18 PDT 2008
Author: dda
Date: 2008-08-25 14:45:14 -0700 (Mon, 25 Aug 2008)
New Revision: 10771
Modified:
openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt
openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTModifiedDefinition.java
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/ScriptCompiler.java
Log:
Change 20080820-dda-z by dda at lester.local on 2008-08-20 16:47:43 EDT
in /Users/dda/laszlo/src/svn/openlaszlo/trunk-c
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: Allow public/protected/private/internal as identifiers; better error messages for other keywords
New Features:
Bugs Fixed: LPP-6576 [Syntax error without reporting file name or line number w/ 4.1]
Technical Reviewer: ptw (pending)
QA Reviewer: (pending)
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details:
The two problems discussed in the JIRA are:
- 'public/protected/private/internal' are not allowed as identifiers
- when certain kinds of errors occur, no line number is given
The first of these is straightforward to fix - public/protected/private/internal
are no longer keywords in the grammar, but they are recognized as
'special' namespace identifiers. This allows them to be also used as
names of classes, vars, etc. so that previously working programs that happened
to use 'public' as the name of a view, or other variable, can continue to work.
The second is more difficult to solve in the general case - syntax errors are
apparently not well handled by our version of JavaCC. Upgrading to a newer
JavaCC is not a trivial exercise - I did spend a few hours on it, and it may
be something we want/need to do eventually. For the time being, I ensured that
every keyword known in our grammar can either be used as an identifier for
view, etc. *or* it is known by the tag compiler to be forbidden, so a proper error
message can be given. This does not completely solve the general problem of being
able to create programs that have mysterious syntax errors, but it should solve
to class of problems where a view or other tag is named with a keyword.
Tests:
- Test case given in LPP-6576.
- Enhanced the same test case using all keywords found in Parser.jjt, for example
<view name="true"/> will no longer give a mysterious error message.
- Regression: smokecheck (DHTML,SWF8), lzpix (ALL), weather (ALL), hello (SWF9)
Modified: openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt 2008-08-25 21:03:03 UTC (rev 10770)
+++ openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt 2008-08-25 21:45:14 UTC (rev 10771)
@@ -206,11 +206,7 @@
| < IMPLEMENTS: "implements" >
| < IMPORT: "import" >
| < INTERFACE: "interface" >
-| < INTERNAL: "internal" >
| < OVERRIDE: "override" >
-| < PRIVATE: "private" >
-| < PROTECTED: "protected" >
-| < PUBLIC: "public" >
| < STATIC: "static" >
| < SUPER: "super" >
@@ -407,7 +403,6 @@
// Newer AS3 keywords are allowed as identifiers, other
// keywords (like public, private, protected) apparently are not
( t=<IDENTIFIER>
- | t=<INTERNAL>
| t=<FINAL>
| t=<STATIC>
| t=<OVERRIDE>
@@ -1147,14 +1142,6 @@
(
t = <IDENTIFIER>
{mod.setToken(t).setNamespace(t.image); }
- | t = "public"
- {mod.setToken(t).setAccess(ASTModifiedDefinition.PUBLIC_ACCESS);}
- | t = "protected"
- {mod.setToken(t).setAccess(ASTModifiedDefinition.PROTECTED_ACCESS);}
- | t = "internal"
- {mod.setToken(t).setAccess(ASTModifiedDefinition.INTERNAL_ACCESS);}
- | t = "private"
- {mod.setToken(t).setAccess(ASTModifiedDefinition.PRIVATE_ACCESS);}
| t = "static"
{mod.setToken(t).setStatic(true);}
| t = "final"
Modified: openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTModifiedDefinition.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTModifiedDefinition.java 2008-08-25 21:03:03 UTC (rev 10770)
+++ openlaszlo/trunk/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTModifiedDefinition.java 2008-08-25 21:45:14 UTC (rev 10771)
@@ -57,7 +57,19 @@
}
public void setNamespace(String value) {
- if (access != DEFAULT_ACCESS) {
+ if ("public".equals(value)) {
+ setAccess(PUBLIC_ACCESS);
+ }
+ else if ("protected".equals(value)) {
+ setAccess(PROTECTED_ACCESS);
+ }
+ else if ("internal".equals(value)) {
+ setAccess(INTERNAL_ACCESS);
+ }
+ else if ("private".equals(value)) {
+ setAccess(PRIVATE_ACCESS);
+ }
+ else if (access != DEFAULT_ACCESS) {
throw new ParseException(t, "cannot use namespace \"" + value + "\" with visibility \"" + access + "\"");
}
if (namespace != null) {
Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/ScriptCompiler.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/ScriptCompiler.java 2008-08-25 21:03:03 UTC (rev 10770)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/ScriptCompiler.java 2008-08-25 21:45:14 UTC (rev 10771)
@@ -361,10 +361,9 @@
for (int i = 1; i < s.length(); i++)
if (!Character.isJavaIdentifierPart(s.charAt(i)))
return false;
- s = s.intern();
- String[] keywords = {"break", "continue", "delete", "else", "for", "function", "if", "in", "instanceof", "new", "return", "this", "typeof", "var", "void", "while", "with", "case", "catch", "class", "const", "debugger", "default", "do", "enum", "export", "extends", "finally", "import", "super", "switch", "throw", "try"};
+ String[] keywords = {"break", "continue", "delete", "else", "false", "for", "function", "if", "implements", "in", "inherits", "interface", "instanceof", "mixin", "new", "null", "return", "this", "trait", "true", "typeof", "var", "void", "while", "with", "case", "catch", "class", "const", "debugger", "default", "do", "enum", "export", "extends", "finally", "import", "super", "switch", "throw", "try"};
for (int i = 0; i < keywords.length; i++) {
- if (s == keywords[i])
+ if (s.equals(keywords[i]))
return false;
}
return true;
More information about the Laszlo-checkins
mailing list