-
Notifications
You must be signed in to change notification settings - Fork 58
Vararg class params and operator identifiers #112
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,8 +55,8 @@ module.exports = grammar({ | |
$._pattern, | ||
$._semicolon, | ||
$._definition, | ||
$._type_identifier, | ||
$._param_type, | ||
$._identifier, | ||
$.literal, | ||
], | ||
|
||
|
@@ -278,7 +278,7 @@ module.exports = grammar({ | |
), | ||
|
||
_type_parameter: $ => seq( | ||
field('name', choice($.wildcard, $.identifier)), | ||
field('name', choice($.wildcard, $._identifier)), | ||
field('type_parameters', optional($.type_parameters)), | ||
field('bound', optional($.upper_bound)), | ||
field('bound', optional($.lower_bound)), | ||
|
@@ -445,7 +445,7 @@ module.exports = grammar({ | |
|
||
// Created for memory-usage optimization during codegen. | ||
_function_constructor: $ => prec.left(PREC.control, seq( | ||
field('name', choice($.identifier, $.operator_identifier)), | ||
field('name', $._identifier), | ||
field('type_parameters', optional($.type_parameters)), | ||
field('parameters', repeat($.parameters)), | ||
optional(seq(':', field('return_type', $._type))), | ||
|
@@ -556,6 +556,7 @@ module.exports = grammar({ | |
optional(choice('val', 'var')), | ||
field('name', $.identifier), | ||
optional(seq(':', field('type', $._type))), | ||
optional('*'), | ||
optional(seq('=', field('default_value', $.expression))) | ||
), | ||
|
||
|
@@ -634,7 +635,7 @@ module.exports = grammar({ | |
|
||
infix_type: $ => prec.left(PREC.infix, seq( | ||
field('left', choice($.compound_type, $.infix_type, $._annotated_type)), | ||
field('operator', choice($.identifier, $.operator_identifier)), | ||
field('operator', $._identifier), | ||
field('right', choice($.compound_type, $.infix_type, $._annotated_type)) | ||
)), | ||
|
||
|
@@ -698,13 +699,13 @@ module.exports = grammar({ | |
'*', | ||
), | ||
|
||
_type_identifier: $ => alias($.identifier, $.type_identifier), | ||
_type_identifier: $ => alias($._identifier, $.type_identifier), | ||
|
||
// --------------------------------------------------------------- | ||
// Patterns | ||
|
||
_pattern: $ => choice( | ||
$.identifier, | ||
$._identifier, | ||
$.stable_identifier, | ||
$.capture_pattern, | ||
$.tuple_pattern, | ||
|
@@ -726,7 +727,7 @@ module.exports = grammar({ | |
|
||
infix_pattern: $ => prec.left(PREC.infix, seq( | ||
field('left', $._pattern), | ||
field('operator', choice($.identifier, $.operator_identifier)), | ||
field('operator', $._identifier), | ||
field('right', $._pattern), | ||
)), | ||
|
||
|
@@ -938,7 +939,7 @@ module.exports = grammar({ | |
$.prefix_expression, | ||
$._simple_expression, | ||
)), | ||
field('operator', choice($.identifier, $.operator_identifier)), | ||
field('operator', $._identifier), | ||
field('right', choice( | ||
$.prefix_expression, | ||
$._simple_expression, | ||
|
@@ -954,7 +955,7 @@ module.exports = grammar({ | |
$.prefix_expression, | ||
$._simple_expression, | ||
), | ||
choice($.identifier, $.operator_identifier), | ||
$._identifier, | ||
)), | ||
|
||
/** | ||
|
@@ -1030,9 +1031,11 @@ module.exports = grammar({ | |
|
||
symbol_literal: $ => '__no_longer_used', | ||
|
||
// TODO: Include operators. | ||
_plainid: $ => /[a-zA-Z_\\$][\w\\$]*/, | ||
_backquoted_id: $=> /`[^\n`]+`/, | ||
|
||
_identifier: $ => choice($.identifier, $.operator_identifier), | ||
|
||
identifier: $ => choice( | ||
$._plainid, | ||
$._backquoted_id, | ||
|
@@ -1045,7 +1048,7 @@ module.exports = grammar({ | |
|
||
wildcard: $ => '_', | ||
|
||
operator_identifier: $ => /[^\s\w\(\)\[\]\{\}'"`\.;,]+/, | ||
operator_identifier: $ => /[!#%&*+-\/:<=>?@'^\|‘~]+/, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a more precise match, from https://docs.scala-lang.org/scala3/reference/syntax.html# What it doesn't match is unicode characters from Sm, So, that's why in Predef this is an error: @deprecated("Use `->` instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.", "2.13.0")
def →[B](y: B): (A, B) = ->(y) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't want to include all the characters from those character sets (thousands), so I think we can live with the limitation that ligatures will cause errors in the grammar There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. People shouldn't be using ligatures anyways. ASCII or die. |
||
|
||
_non_null_literal: $ => | ||
choice( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,9 @@ | |
|
||
# This is an integration test to generally check the quality of parsing. | ||
|
||
SCALA_SCALA_LIBRARY_EXPECTED=95 | ||
SCALA_SCALA_LIBRARY_EXPECTED=98 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚀 |
||
SCALA_SCALA_COMPILER_EXPECTED=63 | ||
DOTTY_COMPILER_EXPECTED=60 | ||
DOTTY_COMPILER_EXPECTED=63 | ||
|
||
if [ ! -d "$SCALA_SCALA_DIR" ]; then | ||
echo "\$SCALA_SCALA_DIR must be set" | ||
|
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 honestly don't know what this is.
Found tree-sitter/tree-sitter#1043 but not sure I understand both the issue and a way to fix it..