This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 115662 - Invalid Syntax error
Summary: Invalid Syntax error
Status: RESOLVED FIXED
Alias: None
Product: web
Classification: Unclassified
Component: HTML Editor (show other bugs)
Version: 6.x
Hardware: All Windows XP
: P2 blocker (vote)
Assignee: Jan Jancura
URL:
Keywords:
: 114698 117404 120434 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-09-17 07:02 UTC by nigel_bris
Modified: 2009-05-18 10:45 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description nigel_bris 2007-09-17 07:02:41 UTC
The follwoing code produces a syntax error within rhtml files

<li style="margin-left: <%=indent -%>" >
Comment 1 Torbjorn Norbye 2007-10-30 16:58:49 UTC
Marek, this is the issue I wrote about yesterday. 

(There are several duplicates. I'm making a pass over the unevaluated bugs today so I'll add several here. Note again
that this isn't specific to one language; the scenario I mentioned yesterday had a parsing error in HTML - the below
appears to be within CSS. I believe the root problem is the GLF parser not handling the embedded language regions
correctly.)
Comment 2 Torbjorn Norbye 2007-10-30 17:04:21 UTC
*** Issue 116545 has been marked as a duplicate of this issue. ***
Comment 3 Torbjorn Norbye 2007-10-30 17:05:34 UTC
*** Issue 114698 has been marked as a duplicate of this issue. ***
Comment 4 Torbjorn Norbye 2007-10-30 18:58:05 UTC
*** Issue 117404 has been marked as a duplicate of this issue. ***
Comment 5 Jan Jancura 2007-10-30 20:45:59 UTC
I do not know how to fix it on my side.
css-inlined grammar fires Syntax error, because "margin-left:" is not valid.
Comment 6 Torbjorn Norbye 2007-10-30 21:11:20 UTC
Hi Hanz, 
I don't see how I can do anything about this from the Ruby side since it's -Schliemann- which is generating the Syntax
Error. Apologies for changing the bug categories back and forth but I think this needs to be addressed in
languages/engine; if what I need to do (suppress errors) is already possible, please tell me how.

I believe the error here is that Schliemann generates an error message when it should not. When Schliemann sees that the
source it's trying to parse has an embedded region within it, with a language it does not recognize, it should not try
to parse it - or at least it should not report errors on it!

<li style="margin-left: <%=indent -%>" > is valid source - it's just an embedding scenario that's not handled by a
Schliemann grammar.

As I wrote to the scripting alias, I need at least a way to turn off parsing of CSS and HTML for RHTML documents, but it
would be much better if this wasn't done globally but only for places where you detect embedding scenarios you can't handle.

I think the simplest way to fix this would be to go to the error handler and when you've generated a SyntaxError,
suppress it if you discover that it's near an embedded language that you're not handling.

(As I also mentioned in my scripting mail, I think it would be very beneficial to include the name of the language next
to "Syntax Error." such that there's no ambiguity as to which language parser is unhappy - CSS, HTML, Ruby, ...?  Would
you like a separate issue filed on that?)

Comment 7 Marek Fukala 2007-10-30 22:39:16 UTC
I am sorry guys, but it looks like this is my fault - I think I am incorrectly creating the css embedding also on the
closing quotation mark in the style tag value. 

The same usecase mentioned by Tor doesn't work in JSP, but works as content of <style> tag.

I'll double check and potentially fix in the morning. 

Sorry for that :-|
Comment 8 Torbjorn Norbye 2007-10-30 22:49:30 UTC
Hi Marek,
There are some other scenarios too (see the duplicates). Here's an embedded JavaScript scenario (from duplicate 114698)
which has nothing to do with CSS:

<input type="submit" name="save" value="Save"
 onClick="document.route = '<%= url_for :action=>@action, :page_id=>@page.name %>';" />

There are some other CSS scenarios to check after you fix the first scenario:
(1) (this is from my mail to the scripting alias yesterday)

<style type="text/css">
<!--
   @import "<% stylesheet_path "faen" %>";
-->
</style>

(2) (From duplicate 117404)
<div style="width: 100%; margin:0;padding:0; background: #dedede; overflow: auto; width: 100%; height: <%=
"#{@list_height}px;" %>" >
Comment 9 Torbjorn Norbye 2007-10-31 01:45:56 UTC
*** Issue 120434 has been marked as a duplicate of this issue. ***
Comment 10 Marek Fukala 2007-10-31 10:34:00 UTC
I am sorry, my previous evaluation was incorrect, I was too tired in the night :-(. The css embedding is created
correctly (not encompassing the quotation mark). It looks like the problem is if the GAP (something from higher level
language) is at the end of the section. In such case the hack with joining token from LLSyntaxAnalyzer doesn't work. We
agreed with Hanz he will extend the hack it the way that the GAP is always added at the end of the section. There might
be some situations at the end of the sections stating to be correct althought they aren't, but it looks like its better
than the false alarms. Thanks Hanzi.
Comment 11 Jan Jancura 2007-10-31 10:57:56 UTC
Hi Tor and Marek.

First, sorry that I am not reacting on some emails - I am really busy - fixing... Feel free to file bug if you need some
change.

Detection of embedded piece of code is not trivial, on my side. Thats because handcoded rhtml lexer (the same is true
for JSP) use different hierarchy of tokens that I am expecting (top level language <> bottom level language).
Preprocessor language (JSP, Ruby) should be on the bottom level of tokens hierarchy, I think. I am not able correctly
detect embeddings in current hierarchy. So, I am forced to do some hacks on my side. We are working on it with Marek.

Switching parser off on some parts of source file is not a good solution, I think. User will have problem to recognize
whats going on - why some parts of his source has no representation in Navigator, why code completion does not work in
some parts of text...

I will help Marek to find some workarround for this issue.

Anyway, this issue is reproducible on rhtml files, so it should be assigned to ruby/rhtml. But I am leaving it here.


Comment 12 Jan Jancura 2007-11-01 09:47:05 UTC
First usecase "<li style="margin-left: <%=indent -%>" >" fixed on my side. But it looks like there is still some issue
in HTML lexer.

IDE:-------------------------------------------------
IDE: [11/1/07 9:44 AM] Committing "SLexer.java" started
Checking in SLexer.java;
/cvs/languages/engine/src/org/netbeans/modules/languages/lexer/SLexer.java,v  <--  SLexer.java
new revision: 1.29; previous revision: 1.28
done
IDE: [11/1/07 9:44 AM] Committing "SLexer.java" finished
Comment 13 Jan Jancura 2007-11-01 10:01:59 UTC
second example "<input type="submit" name="save" value="Save"
 onClick="document.route = '<%= url_for :action=>@action, :page_id=>@page.name %>';" />"

looks like the error is caused by HTML lexer too. 
Comment 14 Jan Jancura 2007-11-01 10:12:40 UTC
Looks like all examples mentioned in this issue fails because of HTML lexer.
Can you look at it, Marek?
Comment 15 Marek Fukala 2007-11-01 20:28:22 UTC
I am affraid the fix introduced a regression:

Put <div style="a:<%="x" %>" > into an empty JSP, you will get IOOBE from parser:

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
	at java.util.ArrayList.RangeCheck(ArrayList.java:547)
	at java.util.ArrayList.get(ArrayList.java:322)
	at org.netbeans.modules.languages.parser.LLSyntaxAnalyser.join(LLSyntaxAnalyser.java:522)
	at org.netbeans.modules.languages.parser.LLSyntaxAnalyser.skipEmbedding(LLSyntaxAnalyser.java:499)
...

Comment 16 Marek Fukala 2007-11-01 20:50:50 UTC
I'll look at the html lexer problem tomorrow.
Comment 17 Jan Jancura 2007-11-02 00:06:31 UTC
regression is fixed now:
IDE: [11/2/07 12:05 AM] Committing "LLSyntaxAnalyser.java" started
Checking in LLSyntaxAnalyser.java;
/cvs/languages/engine/src/org/netbeans/modules/languages/parser/LLSyntaxAnalyser.java,v  <--  LLSyntaxAnalyser.java
new revision: 1.55; previous revision: 1.54
done
IDE: [11/2/07 12:05 AM] Committing "LLSyntaxAnalyser.java" finished
Comment 18 Marek Fukala 2007-11-03 10:46:55 UTC
after the partiall fix of #121033 the status is following:

<input type="submit" name="save" value="Save"
 onClick="document.route = '<%= url_for :action=>@action, :page_id=>@page.name %>';" />

... is ok now

<style type="text/css">
<!--
   @import "<% stylesheet_path "faen" %>";
-->
</style>

The same hack as for javadcript string joining needs to be done also for css, I tried to do that, but it didn't work. I
belive the fix is a 5minutes task for you. Thanks.

<div style="width: 100%; margin:0;padding:0; background: #dedede; overflow: auto; width: 100%; height: <%=
"#{@list_height}px;" %>" >
... this always worked for me. The line is marked as unfinished tag, which is correct.

I belive if you fix the style string joining, we can close this issue.

I cannot say it cases are fixed for sure since

java.lang.IndexOutOfBoundsException: Index: 0
	at java.util.Collections$EmptyList.get(Collections.java:2970)
	at org.netbeans.modules.languages.parser.LLSyntaxAnalyser.join(LLSyntaxAnalyser.java:522)
	at org.netbeans.modules.languages.parser.LLSyntaxAnalyser.skipEmbedding(LLSyntaxAnalyser.java:499)
	at org.netbeans.modules.languages.parser.LLSyntaxAnalyser.readEmbeddings(LLSyntaxAnalyser.java:417)
	at org.netbeans.modules.languages.parser.LLSyntaxAnalyser.read2(LLSyntaxAnalyser.java:336)
	at org.netbeans.modules.languages.parser.LLSyntaxAnalyser.read(LLSyntaxAnalyser.java:153)
	at org.netbeans.modules.languages.ParserManagerImpl.parse(ParserManagerImpl.java:359)
	at org.netbeans.modules.languages.ParserManagerImpl.parseAST(ParserManagerImpl.java:309)
	at org.netbeans.modules.languages.ParserManagerImpl.access$100(ParserManagerImpl.java:84)
	at org.netbeans.modules.languages.ParserManagerImpl$1.run(ParserManagerImpl.java:181)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:561)
[catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:986)

is still thrown. But at least the embeddings are created properly now (taking into account #121046)
Comment 19 Jan Jancura 2007-11-04 09:08:31 UTC
java.lang.IndexOutOfBoundsException fixed

<style type="text/css">
<!--
   @import "<% stylesheet_path "faen" %>";
-->
</style>
Has already been fixed. Marek, you do not have up to date sources, probably.

<div style="width: 100%; margin:0;padding:0; background: #dedede; overflow: auto; width: 100%; height: <%=
"#{@list_height}px;" %>" >
Works for me too.

So, looks like issue is fixed.
Comment 20 Marek Fukala 2007-11-04 10:52:40 UTC
you are right, the css strings joining works fine. The issue is fixed.