-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
enh(elixir) Improves and fixes many issues with Elixir grammar #3212
enh(elixir) Improves and fixes many issues with Elixir grammar #3212
Conversation
src/languages/elixir.js
Outdated
const DEFSTRUCT = { | ||
className: 'class', | ||
beginKeywords: 'defstruct' | ||
// ends immediately |
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.
class
is deprecated now. More likely you'd want this to be a newer multi-match rule and then use title.class
for the name of the struct... See wren.js
for examples. I can also do this myself after though... I already had a few commits patching the other declarations to the newer standard but decided they didn't fit in our regex fix PR.
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.
Hmm... since the struct's name is not part of the defstruct
call but it's defined by the module name in which defstruct
is called, I think I just need to make defstruct
a keyword instead?
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.
iex> defmodule User do
...> defstruct name: "John", age: 27
...> end
Ah, yes, just a keyword then for defstruct
... defmodule
though would probably be a multi-matcher.
@@ -1,4 +1,8 @@ | |||
a = """test""" | |||
b = '''test''' |
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.
I see how these are better examples (that you added), but if the previous were valid we should also leave them to serve as additional regression tests... one can still use a multi-line string for a single line - that is valid grammar, yes?
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.
that is valid grammar, yes?
No, those were syntax errors in Elixir. The only allowed characters after the opening '''
/"""
is optional whitespace, and then a newline is required.
My assumption is that it's not a big deal if the syntax highlighting colors something that doesn't compile so I didn't feel the need to change the regexes for multiline strings, but the test examples should be valid Elixir code, right?
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.
No, those were syntax errors in Elixir.
Whoa. I stand corrected. ;-)
My assumption is that it's not a big deal if the syntax highlighting colors something that doesn't compile
Right, it's not our job to detect invalid code.
but the test examples should be valid Elixir code, right?
For the most part, yes. In this particular case this indeed makes sense. I just see people "swap" test cases often when they should be adding new cases instead, [not removing old ones]. Thought this was perhaps yet another case of that. :)
Perhaps we could add |
- enh(elixir) updated list of keywords (#3212) [Angelika Tyborska][] | ||
- fix(elixir) fixed number detection when numbers start with a zero (#3212) [Angelika Tyborska][] |
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.
I'm assuming the id should be the PR id, not the issue id?
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.
Yep
@angelikatyborska Thanks so much! |
Closes #3210
Closes #3211
Changes
defmacro
is a function definition,defmacrop
should be toodefrecord
is a class definition,defstruct
should be tooChecklist
nil
,true
,false
)0
as a numberCHANGES.md