Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update ace syntax to fix lua 5.3 bitwise op parse errors #9

Closed
tehn opened this issue Feb 13, 2018 · 11 comments · Fixed by #197
Closed

update ace syntax to fix lua 5.3 bitwise op parse errors #9

tehn opened this issue Feb 13, 2018 · 11 comments · Fixed by #197
Assignees

Comments

@tehn
Copy link
Member

tehn commented Feb 13, 2018

seems to be using an earlier version of lua. for example, sees bit shifting as an error.

@ngwese ngwese added the good first issue Good for newcomers label May 2, 2018
@jlmitch5
Copy link
Collaborator

jlmitch5 commented May 2, 2018

I think we are up-to-date in terms of what Ace has for lua syntax.

Looks to me like this would need to be fixed at the ace level (it doesn't seem like there's a scanPunctuator(>>) assuming that's what you mean by bitshifting (Nor is there <<)

https://github.com/ajaxorg/ace/blob/master/lib/ace/mode/lua/luaparse.js#L545

@ngwese
Copy link
Member

ngwese commented May 2, 2018

well that is a bummer. i wonder how much effort it would be to roll our own build (with some enhancements) and then submit the changes back to the Ace repo...

@jlmitch5
Copy link
Collaborator

jlmitch5 commented May 2, 2018

It looks like the react-ace component uses brace which embeds a version of ace (there are a bunch of commits with messages like "update to using ace 1.2.9". So I went to look there and that's how I happened upon the line above in the ace lib's lua mode files. brace seems to have its own (different?) parsing stuff...which also doesn't mention the shifting ops >> and <<

https://github.com/thlorenz/brace/blob/master/mode/lua.js#L139

--

Both what we'd change and how we'd roll our own is a little unclear on this one, and I feel like this one might be a bit of a rabbit-hole. Also could be totally possible I'm making this harder than it actually is.

I think some further investigation could be good, but unfortunately, I don't think this one is going to be as easy as bump the package.json version :/

@pq
Copy link
Collaborator

pq commented Jun 19, 2018

doing a bit more digging, i think the bit we want to see update is luaparse.js; specifically, we'd want to add some new case logic around here:

https://github.com/ajaxorg/ace/blob/master/lib/ace/mode/lua/luaparse.js#L544-L546

(EDIT: @jlmitch5 already noted this... consider it doubly confirmed! 😀)

@pq
Copy link
Collaborator

pq commented Jun 19, 2018

i think the fix is actually easy; the tough part is integrating it. (i'm looking at #78 which is harder than you'd think 😬; in this case, we'd have to clobber the custom worker that does the annotating and replace it with our own that uses a modified parser. investigating.)

@ngwese ngwese changed the title ace syntax update update ace syntax to fix lua 5.3 bitwise op parse errors Jul 1, 2018
@Dewb
Copy link
Contributor

Dewb commented Oct 12, 2019

Another 5.3 feature that Ace doesn't handle correctly is the // floor-division operator. It reports a red-x error with <expression> expected near '/'.

(Mainly mentioning this here so if someone else searches for this error, this issue is more likely to come up.)

@ngwese
Copy link
Member

ngwese commented May 14, 2020

At this point I’d be happy to just maintain a local fork of the lua syntax if someone could figure out how to get ace to load it instead of the built in.

@tlubke
Copy link

tlubke commented May 14, 2020

I'm wondering if this would be a solution, found from the Ace website:

Configure dynamic loading of modes and themes

By default ace detcts the url for dynamic loading by finding the script node for ace.js. This doesn't work if ace.js is not loaded with a separate script tag, and in this case it is required to set url explicitely

ace.config.set("basePath", "https://url.to.a/folder/that/contains-ace-modes");

Maybe we could create a fork on github like suggested above, and just point the config there?

@pq
Copy link
Collaborator

pq commented May 14, 2020

hey @tlubke. i would love if this turned out to be possible. TBH i can't recall if i tried but it sure feels promising.

as for the syntax fixes proper, i'm happy to help shepherd them in (and really we should just upstream them while we're at it).

cheers!

@pq
Copy link
Collaborator

pq commented May 14, 2020

(oh wait, i'm remembering now: maybe this is not as straight-forward because ace is bundled in a react wrapper?)

@ngwese
Copy link
Member

ngwese commented Dec 28, 2020

...oldest ticket on the list, back from the dead. on a whim i looked to see if the react-ace package has been updated. currently maiden uses v5.1.0 and the latest version is (cough) v9.2.1. after some fairly trivial edits it looks like the newer version might be more or less a drop in. on an encouraging note testing so far has shown that the new version:

  • fixes parsing of << and >> operators so they are no longer flagged as bad
  • correctly de-indents end keywords when completing a block

i'm going to push forward and see if i can get the maiden's dark mode working as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants