Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[wtp-incubator-dev] getCharPositionInLine() problems when token is inside quotation marks / apostrophes

Good morning,

I've been using the XQDT code as part of my studies, and I've come across a problem I can't seem to solve or find its origin. Maybe you have been in a similar situation and might be able to help me.

After parsing the code and getting the module's tree ( XQueryParser.p_module_return m = parser.p_Module; CommonTree tree = (CommonTree)m.getTree(); ), I try to get each of its child's position in line (org.antlr.runtime.Token's getCharPositionInLine() ) but every time I include either Quotation Marks or Apostrophes, I get the wrong value for the subsequent tokens. 
If we consider the following piece of XQuery code in the editor as an example:

let $e := doc(document.xml)/a/b
return $e/c


Calling getCharPositionInLine() for the token ‘document.xml’ returns ‘14’, which is correct. If, on the other hand, I add Quotation Marks or Apostrophes (adding the correct syntax to the XQuery code) as in:


let $e := doc("document.xml")/a/b
return $e/c


I then get '27' (instead of '15') as the token 'document.xml's position in line and '41' as the token ')'s position in line. Every subsequent token in the same line has its position increased by the length of the token inside the QMs plus one (13 in this case). 

Would anyone be able to help me understand why this happens? 


Many thanks in advance,

Lorena G.

Back to the top