Commit Graph

12 Commits

Author SHA1 Message Date
Jens Johansen 4ee8852d77 [CFE/parser] Update 'end' on endLiteralString; Set offset of StringConcatenation to the start; rename 'token' to 'operatorToken' on endBinaryPatterns
* The 'end' token on endLiteralString is now the last token of the
   string, not the next unrelated token.
 * Set the offset of StringConcatenation to the start of the string,
   not the start of the next unrelated token.
 * The 'end' token on endBinaryPatterns is renamed to 'operatorToken'.

Fixes https://github.com/dart-lang/sdk/issues/55690

Tested: Existing
Change-Id: Iae788464008594c21e759570a626971d89688033
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498601
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-04-30 01:05:23 -07:00
Johnni Winther 0a154753c6 [parser][InternalNodes] Add handlePositionalArgument and handlePositionalRecordField
This [handlePositionalArgument] and [handlePositionalRecordField] methods to the parser listener, allowing listeners to normals arguments and record fields

Change-Id: I3947e196dafffea2ab383f797904c857db8327ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469620
Reviewed-by: Jens Johansen <jensj@google.com>
2026-01-06 02:30:12 -08:00
Johnni Winther be29db2621 [cfe] Update parser suites to use FolderOptions
This updates the parser suites to use the FolderOptions already used by other expectation tests. This aligns the support for configuration tests in particular wrt experimental flags.

As a consequence of this change, all parser suite enable patterns for parser. Since the test setup didn't use experimental flags previously, newly added tests didn't use the current default, which is with pattern support. Since we don't have any tests explicitly for non-pattern support, all tests are updated to support patterns as it at least aligns with the default for current and future code.

Change-Id: I80ee769b35e74a0d111135ca4690983872a63623
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/459741
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-11-06 03:43:55 -08:00
Johnni Winther 02c3d9c3f0 [parser] Support declaring parameters
This allows `var int a` in primary constructors when the declaring constructors feature is enabled.

Part of https://github.com/dart-lang/sdk/issues/61699

Change-Id: I486ad8aa3ddbe09451455b024b3aa9cfbaa9a5e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456340
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-10-22 01:46:47 -07:00
Lasse R.H. Nielsen 56b68442fe Parse ?. as ?+. in element.
Bug: https://dartbug.com//language/4477

Change-Id: If68b21a2b22ed65dde09c03dab8a3f4721a2fa34
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442480
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2025-08-04 03:21:33 -07:00
Jens Johansen 59f19d8771 [parser] Shortcut common case in parseArgumentsRest
Observation: Often when about to call parseExpression in
parseArgumentsRest we see either "<identifier> <comma>" (say, we're
passing a variable) or "<identifier> <end parens>" (same case, but last
argument).

This CL allows us to shortcut such cases avoiding a lot of calls where
we check if it's other cases which it isn't.

pkg/analyzer/lib/src/dart/ast/ast.dart:

JIT (tokens per microsecond):
5.5605% +/- 4.0086% (1.16 +/- 0.84) (20.94 -> 22.10)

AOT (tokens per microsecond):
7.1788% +/- 2.5682% (2.04 +/- 0.73) (28.44 -> 30.48)

Benchmarker (AOT):
```
msec task-clock:u: -4.4173% +/- 1.7793% (-124.29 +/- 50.07) (2813.81 -> 2689.52)
page-faults:u: 0.1064% +/- 0.0131% (10.90 +/- 1.35) (10246.00 -> 10256.90)
cycles:u: -4.4718% +/- 1.7882% (-546472914.30 +/- 218528412.28) (12220314431.60 -> 11673841517.30)
instructions:u: -10.0011% +/- 0.0000% (-2704578213.40 +/- 1611.58) (27042820700.90 -> 24338242487.50)
seconds time elapsed: -4.4160% +/- 1.7779% (-0.12 +/- 0.05) (2.82 -> 2.69)
seconds user: -4.6324% +/- 1.8285% (-0.13 +/- 0.05) (2.80 -> 2.67)
```


pkg/front_end/lib/src/type_inference/inference_visitor.dart:

JIT (tokens per microsecond):
10.1981% +/- 1.2476% (1.58 +/- 0.19) (15.46 -> 17.04)

AOT (tokens per microsecond):
8.7843% +/- 1.5781% (1.79 +/- 0.32) (20.42 -> 22.22)

Benchmarker (AOT):
```
msec task-clock:u: -5.9322% +/- 2.7532% (-181.01 +/- 84.01) (3051.38 -> 2870.37)

page-faults:u: 0.0352% +/- 0.0261% (3.50 +/- 2.59) (9930.90 -> 9934.40)
cycles:u: -6.0726% +/- 2.7273% (-805818237.40 +/- 361907438.70) (13269703092.60 -> 12463884855.20)
instructions:u: -11.9540% +/- 0.0000% (-3561054138.90 +/- 1016.14) (29789745342.80 -> 26228691203.90)
seconds time elapsed: -5.9310% +/- 2.7520% (-0.18 +/- 0.08) (3.05 -> 2.87)
seconds user: -6.1531% +/- 2.7477% (-0.19 +/- 0.08) (3.03 -> 2.85)
```
Change-Id: Ia4fbdcbd438a38a0c07b3f4423812ef3507b626c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439880
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-07-31 00:41:03 -07:00
Jens Johansen 86b65842ed [parser] Manually inline 'isNextIdentifier'
pkg/analyzer/lib/src/dart/ast/ast.dart:

JIT (tokens per microsecond):
2.1064% +/- 1.6771% (0.44 +/- 0.35) (20.97 -> 21.42)

AOT (tokens per microsecond):
No change.

Benchmarker (AOT):
```
msec task-clock:u: -1.2559% +/- 0.6202% (-35.75 +/- 17.65) (2846.58 -> 2810.83)
cycles:u: -1.3051% +/- 0.6113% (-161347113.30 +/- 75579075.11) (12362747585.00 -> 12201400471.70)
instructions:u: -0.6245% +/- 0.0000% (-169931728.50 +/- 1390.09) (27212753414.40 -> 27042821685.90)
seconds time elapsed: -1.2465% +/- 0.6111% (-0.04 +/- 0.02) (2.85 -> 2.81)
seconds user: -1.3083% +/- 0.7709% (-0.04 +/- 0.02) (2.83 -> 2.79)
```


pkg/front_end/lib/src/type_inference/inference_visitor.dart:

JIT (tokens per microsecond):
No change.

AOT (tokens per microsecond):
No change.

Benchmarker (AOT):
```
instructions:u: -0.9284% +/- 0.0000% (-279155451.00 +/- 502.76) (30068900827.90 -> 29789745376.90)
```

Change-Id: I70eaae39d156f77e5e451a8592f6f3dab2da3d67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439780
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-07-30 07:13:16 -07:00
Jens Johansen 752b760308 [parser] notEofOrValue -> notEofOrType - skip string comparison
A small one.

pkg/analyzer/lib/src/dart/ast/ast.dart:

JIT (tokens per microsecond):
1.7597% +/- 1.4621% (0.37 +/- 0.30) (20.79 -> 21.15)

AOT (tokens per microsecond):
2.2547% +/- 1.6761% (0.62 +/- 0.46) (27.67 -> 28.30)

Benchmarker (AOT):
```
msec task-clock:u: -2.4779% +/- 1.3546% (-73.29 +/- 40.07) (2957.87 -> 2884.58)
cycles:u: -2.6238% +/- 1.3918% (-337224094.10 +/- 178886541.74) (12852601263.80 -> 12515377169.70)
instructions:u: -0.9484% +/- 0.0000% (-260552753.00 +/- 375.88) (27473305680.40 -> 27212752927.40)
branch-misses:u: -8.7134% +/- 6.9328% (-3191115.20 +/- 2538992.37) (36623085.10 -> 33431969.90)
seconds time elapsed: -2.4691% +/- 1.3512% (-0.07 +/- 0.04) (2.96 -> 2.89)
seconds user: -2.4294% +/- 1.3675% (-0.07 +/- 0.04) (2.93 -> 2.86)
```


pkg/front_end/lib/src/type_inference/inference_visitor.dart:

JIT (tokens per microsecond):
No change.

AOT (tokens per microsecond):
No change.

Benchmarker (AOT):
```
msec task-clock:u: -4.3099% +/- 1.9546% (-136.28 +/- 61.81) (3162.10 -> 3025.81)
cycles:u: -4.3066% +/- 1.9530% (-592061704.80 +/- 268488936.68) (13747787475.20 -> 13155725770.40)
instructions:u: -0.5194% +/- 0.0000% (-156988901.90 +/- 1876.14) (30225890142.20 -> 30068901240.30)
branch-misses:u: -14.2999% +/- 7.5350% (-6167339.80 +/- 3249736.99) (43128654.50 -> 36961314.70)
seconds time elapsed: -4.3098% +/- 1.9527% (-0.14 +/- 0.06) (3.16 -> 3.03)
seconds user: -4.3252% +/- 1.9575% (-0.14 +/- 0.06) (3.14 -> 3.01)
```

Change-Id: Ib70398e337c482f7427debb6875e2c17ccc6bd0f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439740
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-07-30 07:06:17 -07:00
Jens Johansen e30f60791a [parser] Don't use the next token as the end on handleSend
Change-Id: Ic4bacffab3fdd9d23bea9b1ecd0f2cfdecb82e2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/399060
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-12-05 15:10:34 +00:00
Chloe Stefantsova 0083afa5d5 [parser] Make NullAwareEntry to be treated as a direct entry
Previously NullAwareEntry set the hasEntry property to false, which
meant that it relied on a nested entry element to handle the rest of
its contents. However, according to the grammar for null-aware
elements (see
https://github.com/dart-lang/language/blob/main/accepted/future-releases/0323-null-aware-elements/feature-specification.md#syntax),
null-aware elements and entries are leaf nodes and can only contain
expressions.

This CL also fixes some crashes in the CFE that expects the map
entries appearing in lists to be handled by the parser.

Change-Id: I3d7a3f3e8507a2ef8a290e51b49e4749260dfcda
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389900
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-10-16 07:45:41 +00:00
Chloe Stefantsova 06223ff9f0 [parser] Add missing handling of null-aware elements in if-else
Part of https://github.com/dart-lang/sdk/issues/55954

Change-Id: Ie22ff9ddf50f47e20b1cfbf11f01bdc900123619
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388003
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2024-10-07 09:41:35 +00:00
Chloe Stefantsova a4c94716ba [analyzer][cfe] Introduce parsing for null-aware elements
Part of https://github.com/dart-lang/sdk/issues/55949
Closes https://github.com/dart-lang/sdk/issues/55954

Change-Id: I885772f292f6d70425d6eba15bad8b0c6dc86a1f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370240
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-06-28 09:49:30 +00:00