Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Issue 2682423003: Unify fasta->analyzer token translation logic. (Closed)

Created:
3 years, 10 months ago by Paul Berry
Modified:
3 years, 10 months ago
CC:
reviews_dartlang.org
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Unify fasta->analyzer token translation logic. Previously, the scanner tests and the Fasta implementation had duplicate logic for translating Fasta tokens to analyzer tokens. This CL unifies the translation logic, and fills in some functionality that was missing from the Fasta translation logic. R=ahe@google.com Committed: https://github.com/dart-lang/sdk/commit/85028a844f6c8932449746d9361c5467caea34bc

Patch Set 1 #

Total comments: 9
Unified diffs Side-by-side diffs Delta from patch set Stats (+168 lines, -267 lines) Patch
M pkg/front_end/lib/src/fasta/analyzer/token_utils.dart View 2 chunks +117 lines, -16 lines 9 comments Download
M pkg/front_end/test/scanner_fasta_test.dart View 4 chunks +2 lines, -251 lines 0 comments Download
M pkg/front_end/test/scanner_test.dart View 5 chunks +48 lines, -0 lines 0 comments Download
M pkg/front_end/test/subpackage_relationships_test.dart View 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 9 (2 generated)
Paul Berry
3 years, 10 months ago (2017-02-10 13:51:20 UTC) #2
ahe
lgtm https://codereview.chromium.org/2682423003/diff/1/pkg/front_end/lib/src/fasta/analyzer/token_utils.dart File pkg/front_end/lib/src/fasta/analyzer/token_utils.dart (right): https://codereview.chromium.org/2682423003/diff/1/pkg/front_end/lib/src/fasta/analyzer/token_utils.dart#newcode59 pkg/front_end/lib/src/fasta/analyzer/token_utils.dart:59: if (_pseudoKeywords.contains(syntax)) { Would token.isIdentifier or token.isPseudo work ...
3 years, 10 months ago (2017-02-10 14:12:40 UTC) #3
Paul Berry
https://codereview.chromium.org/2682423003/diff/1/pkg/front_end/lib/src/fasta/analyzer/token_utils.dart File pkg/front_end/lib/src/fasta/analyzer/token_utils.dart (right): https://codereview.chromium.org/2682423003/diff/1/pkg/front_end/lib/src/fasta/analyzer/token_utils.dart#newcode59 pkg/front_end/lib/src/fasta/analyzer/token_utils.dart:59: if (_pseudoKeywords.contains(syntax)) { On 2017/02/10 14:12:40, ahe wrote: > ...
3 years, 10 months ago (2017-02-10 17:01:02 UTC) #4
Paul Berry
Committed patchset #1 (id:1) manually as 85028a844f6c8932449746d9361c5467caea34bc (presubmit successful).
3 years, 10 months ago (2017-02-10 17:02:02 UTC) #6
ahe
FYI https://codereview.chromium.org/2682423003/diff/1/pkg/front_end/lib/src/fasta/analyzer/token_utils.dart File pkg/front_end/lib/src/fasta/analyzer/token_utils.dart (right): https://codereview.chromium.org/2682423003/diff/1/pkg/front_end/lib/src/fasta/analyzer/token_utils.dart#newcode59 pkg/front_end/lib/src/fasta/analyzer/token_utils.dart:59: if (_pseudoKeywords.contains(syntax)) { On 2017/02/10 17:01:02, Paul Berry ...
3 years, 10 months ago (2017-02-10 17:10:47 UTC) #7
Paul Berry
https://codereview.chromium.org/2682423003/diff/1/pkg/front_end/lib/src/fasta/analyzer/token_utils.dart File pkg/front_end/lib/src/fasta/analyzer/token_utils.dart (right): https://codereview.chromium.org/2682423003/diff/1/pkg/front_end/lib/src/fasta/analyzer/token_utils.dart#newcode59 pkg/front_end/lib/src/fasta/analyzer/token_utils.dart:59: if (_pseudoKeywords.contains(syntax)) { On 2017/02/10 17:10:46, ahe wrote: > ...
3 years, 10 months ago (2017-02-10 17:20:24 UTC) #8
ahe
3 years, 10 months ago (2017-02-10 17:22:46 UTC) #9
Message was sent while issue was closed.
https://codereview.chromium.org/2682423003/diff/1/pkg/front_end/lib/src/fasta...
File pkg/front_end/lib/src/fasta/analyzer/token_utils.dart (right):

https://codereview.chromium.org/2682423003/diff/1/pkg/front_end/lib/src/fasta...
pkg/front_end/lib/src/fasta/analyzer/token_utils.dart:91: "assert":
analyzer.Keyword.ASSERT,
On 2017/02/10 17:20:24, Paul Berry wrote:
> On 2017/02/10 17:10:46, ahe wrote:
> > On 2017/02/10 17:01:02, Paul Berry wrote:
> > > On 2017/02/10 14:12:40, ahe wrote:
> > > > I think you're not worried about performance right now, so feel free to
> > ignore
> > > > this:
> > > > 
> > > > AFAIK, the built-in map is pretty slow, so one could try a string switch
> > > > instead. However, as far as I know, switches are implemented as a
sequence
> > of
> > > if
> > > > tests, so, at least in theory, this should be fastest:
> > > > 
> > > > analyzer.Keyword keywordFromString(String name) {
> > > >   if (identical("assert", name)) return analyzer.Keyword.BREAK;
> > > >   // And so on.
> > > > }
> > > > 
> > > > The scanner takes care to use string literals for all the keyword
string,
> > and
> > > > this is why it is safe to use identical.
> > > 
> > > You're correct that I'm not worried about performance right now,
especially
> > for
> > > this code (I think it remains to be seen whether this translation layer is
> > going
> > > to be needed in the long term, or whether we will unify Fasta and
analyzer's
> > > token representations).  I've added a TODO so that if this shows up in the
> > > profiler, we won't forget your ideas for speeding it up.
> > 
> > FWIW, my biggest worry about unifying them is the previous token pointer.
But
> it
> > should be easy to investigate the memory overhead in fasta if we add an
> > additional field to tokens, and it might be that bad as fasta doesn't keep
> them
> > in memory as dart2js does.
> 
> Agreed--it's a complex tradeoff.  I don't intend to make any movements in that
> direction without gathering data and opinions first :)

Data and opinions are good :-)

Just to be clear, I left out a negation above. I think the memory overhead might
*not* be that bad.

Powered by Google App Engine
This is Rietveld 408576698