-
Notifications
You must be signed in to change notification settings - Fork 38
support lua5.5 grammar #66
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
Conversation
|
You really need to use the latest version of the |
|
Parse failures look to be genuine regressions: Looks like you can't make @MunifTanjim I think this requires deeper thought about how this grammar handles the various (deliberately incompatible) dialects of Lua. One option would be generate-time extensions like https://github.com/tree-sitter-grammars/tree-sitter-markdown. (I feel like we've been down that hole before...) |
|
Similarly, goto is another example — LuaJIT supports using goto as a field. LuaJIT 2.1.0-beta3 -- Copyright (C) 2005-2017 Mike Pall. http://luajit.org/
JIT: ON SSE2 SSE3 SSE4.1 BMI2 fold cse dce fwd dse narrow loop abc sink fuse
> l = {} l.goto = {}
> print(l.goto)
table: 0x3dcf22c0 |
It does not, at least not without significantly (and unacceptably) complicating the external scanner.
LuaJIT is Lua 5.1, where |
|
I think we can do workaround: replace |
|
I don't think that's a good idea... This will include surrounding whitespace in the corresponding node, which is an absolute deal-breaker for some use cases (which go far beyond highlighting). |
|
Lua 5.5 was a mistake... Joking aside, would a dedicated |
|
Looks like other languages have this issue too, e.g. |
|
@CppCXY can you try this? diff --git a/grammar.js b/grammar.js
index 08a1373..851cbf2 100644
--- a/grammar.js
+++ b/grammar.js
@@ -486,7 +486,7 @@ export default grammar({
// var ::= Name | prefixexp [ exp ] | prefixexp . Name
variable: ($) =>
- choice($.identifier, $.bracket_index_expression, $.dot_index_expression),
+ choice($._contextual_keyword, $.identifier, $.bracket_index_expression, $.dot_index_expression),
// prefixexp [ exp ]
bracket_index_expression: ($) =>
seq(
@@ -627,5 +627,8 @@ export default grammar({
field('end', alias($._block_comment_end, ']]'))
)
),
+
+ // only `global` for now
+ _contextual_keyword: (_) => 'global',
},
});
|
|
can not pass like: {
global = 1
}
|
Try this? diff --git a/grammar.js b/grammar.js
index 851cbf2..f8f820a 100644
--- a/grammar.js
+++ b/grammar.js
@@ -543,7 +543,7 @@ export default grammar({
'=',
field('value', $.expression)
),
- seq(field('name', $.identifier), '=', field('value', $.expression)),
+ seq(field('name', choice($._contextual_keyword, $.identifier)), '=', field('value', $.expression)),
field('value', $.expression)
),
|
ac26e90 to
ac048c8
Compare
|
now, all ci test passed |
MunifTanjim
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍🏼


No description provided.