codemirror / CodeMirror-v1

An editable-iframe based code editor in JavaScript. See https://github.com/marijnh/CodeMirror for the currently maintained version
http://codemirror.net/
Other
362 stars 63 forks source link

xquery parser for CodeMirror #18

Closed mbrevoort closed 13 years ago

mbrevoort commented 14 years ago

Hi,

I wrote an XQuery parser for CodeMirror in a forked repo that I would love to have pulled back in. Here's the demo: http://mbrevoort.github.com/CodeMirror/

Very awesome editor framework by the way!

I marked it with an Apache 2 license but will release under whatever you require as long as it's as open as Apache 2.

Thanks!

LeifW commented 14 years ago

A slight issue with that: Text inside elements that's not surrounded by curly braces should just be text even if it starts with a '$' sign.

mbrevoort commented 14 years ago

There's probably a few other possibilities that creep in there as well like function calls. I should have this fixed soon. Thanks for the feedback!

LeifW commented 14 years ago

The other thing I noticed was that the XML part seemed less full-featured than CodeMirror's existing XML parser - i.e. didn't detect mis-matched closing tags.

marijnh commented 14 years ago

I considered doing this myself at some point, and my idea was to embed the existing XML parser in the XQuery parser (much like, for example, parsehtmlmixed.js embeds JS and CSS parsers). You might want to look into that.

mbrevoort commented 14 years ago

I'm actually thinking of completely refactoring what I did now that I'm better understanding the how the editor works. I had been maintaining a list of the last 5000 previous tokens in the stream to apply context which works on the 1st hightlighting pass but fails sometimes when the context window of the edit clips some needed context. Any suggestions there would be helpful.

I had thought of using the existing XML parser, which I may switch to, but decided not to in the first go around because I would have to deal with stitching back and forth somehow based on context since you can have multiple nestings of xquery like : <xml attr="{xquery}>{xquery, <xml attr="{xquery}>{xquery, {xquery,,xquery}}

marijnh commented 14 years ago

which works on the 1st hightlighting pass but fails sometimes when the context window of the edit clips some needed context. Any suggestions there would be helpful.

I think that can be solved by having your copy method also copy the previousTokens variable. In fact, it should copy and restore all state that the parser keeps, so I think you should also handle some of the other locals.

marijnh commented 13 years ago

This was merged. I forgot to close.