Skip to content

Commit

Permalink
add @= DISTINCT_DECL matcher which maps to 'DECLARATION' token
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmicexplorer committed Nov 16, 2024
1 parent d3ca783 commit ab63299
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/coffeescript/lexer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions src/lexer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,8 @@ exports.Lexer = class Lexer
if match = OPERATOR.exec @chunk
[value] = match
@tagParameters() if CODE.test value
else if match = DISTINCT_DECL.exec @chunk
[value] = match
else
value = @chunk.charAt 0
tag = value
Expand All @@ -781,6 +783,9 @@ exports.Lexer = class Lexer
@error message, origin[2] if message
return value.length if skipToken

if value is '@='
tag = 'DECLARATION'

if value is '(' and prev?[0] is 'IMPORT'
prev[0] = 'DYNAMIC_IMPORT'

Expand Down Expand Up @@ -1479,3 +1484,9 @@ LINE_BREAK = ['INDENT', 'OUTDENT', 'TERMINATOR']
# Additional indent in front of these is ignored.
INDENTABLE_CLOSERS = [')', '}', ']']
# Proposed syntax for "declarations", which are checked to be unique in a scope and can therefore
# have additional semantic information attached which would otherwise be erased.
DISTINCT_DECL = /// ^ (
?: @= # distinct var decl which can have a specific comment attached.
) ///

0 comments on commit ab63299

Please sign in to comment.