Skip to content

Commit

Permalink
fix: allow annotations after new but before the type, add cent unicod…
Browse files Browse the repository at this point in the history
…e to identifiers
  • Loading branch information
amaanq committed Aug 16, 2023
1 parent 602733c commit 3a71471
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ module.exports = grammar({

_unqualified_object_creation_expression: $ => prec.right(seq(
'new',
repeat($._annotation),
field('type_arguments', optional($.type_arguments)),
field('type', $._simple_type),
field('arguments', $.argument_list),
Expand Down Expand Up @@ -1224,7 +1225,7 @@ module.exports = grammar({
super: $ => 'super',

// https://docs.oracle.com/javase/specs/jls/se8/html/jls-3.html#jls-IdentifierChars
identifier: $ => /[\p{L}_$][\p{L}\p{Nd}_$]*/,
identifier: $ => /[\p{L}_$][\p{L}\p{Nd}\u00A2_$]*/,

// http://stackoverflow.com/questions/13014947/regex-to-match-a-c-style-multiline-comment/36328890#36328890
comment: $ => choice(
Expand Down
13 changes: 12 additions & 1 deletion test/corpus/declarations.txt
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ class Point {
Point(int x, int y) {
this.x = x;
this.y = y;
this.ABCâ = new @Anno Point();
}

Point() {
Expand Down Expand Up @@ -472,7 +473,17 @@ class Point {
left: (field_access
object: (this)
field: (identifier))
right: (identifier)))))
right: (identifier)))
(expression_statement
(assignment_expression
left: (field_access
object: (this)
field: (identifier))
right: (object_creation_expression
(marker_annotation
name: (identifier))
type: (type_identifier)
arguments: (argument_list))))))
(constructor_declaration
name: (identifier)
parameters: (formal_parameters)
Expand Down

0 comments on commit 3a71471

Please sign in to comment.