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

Unified Diff: pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart

Issue 2711453002: Implement shell-style comments and record shebangs as comments. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart
diff --git a/pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart b/pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart
index f4de827c7fa5399a8d90e8207653e0b2503b8d77..3532a30d6ecc9ede2f4ba0c85d21049416994cf8 100644
--- a/pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart
+++ b/pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart
@@ -30,8 +30,13 @@ import 'token_constants.dart';
import 'characters.dart';
abstract class AbstractScanner implements Scanner {
+ /// If true, include comments in the token stream.
final bool includeComments;
+ /// If true, `#` starts a single line comment. This is the comment style
+ /// known from, for example, Unix shell and Python.
+ final bool enableShellStyleComments;
ahe 2017/02/21 16:57:10 I should probably remove this again. After thinkin
Paul Berry 2017/02/21 16:59:34 SGTM. I admit I was surprised you were heading do
ahe 2017/02/21 17:37:34 Yeah, it feels like a stupid idea now :-) Sometim
+
/**
* The string offset for the next token that will be created.
*
@@ -57,7 +62,7 @@ abstract class AbstractScanner implements Scanner {
final List<int> lineStarts = <int>[0];
- AbstractScanner(this.includeComments) {
+ AbstractScanner(this.includeComments, this.enableShellStyleComments) {
this.tail = this.tokens;
}
@@ -401,19 +406,10 @@ abstract class AbstractScanner implements Scanner {
int tokenizeTag(int next) {
// # or #!.*[\n\r]
- if (scanOffset == 0) {
- if (identical(peek(), $BANG)) {
- int start = scanOffset + 1;
- bool asciiOnly = true;
- do {
- next = advance();
- if (next > 127) asciiOnly = false;
- } while (!identical(next, $LF) &&
- !identical(next, $CR) &&
- !identical(next, $EOF));
- if (!asciiOnly) handleUnicode(start);
- return next;
- }
+ if (scanOffset == 0 && identical(peek(), $BANG)) {
+ tokenizeSingleLineComment(next, scanOffset + 1);
+ } else if (enableShellStyleComments) {
+ tokenizeSingleLineComment(next, scanOffset);
}
appendPrecedenceToken(HASH_INFO);
return advance();
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698