mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
Add (already referenced) initial docs for tokens
Change-Id: I8edb453f638223464ffb8563c8d4fe0dd6999991 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269360 Reviewed-by: Samuel Rawlins <srawlins@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
715866aed3
commit
f50c52f3dd
1 changed files with 13 additions and 0 deletions
13
pkg/analyzer/doc/tutorial/tokens.md
Normal file
13
pkg/analyzer/doc/tutorial/tokens.md
Normal file
|
@ -0,0 +1,13 @@
|
|||
# The Token stream
|
||||
|
||||
The token stream is a doubly linked list with special 'EOF' tokens at the
|
||||
beginning and end. The EOF token at the end points to itself as the `next`
|
||||
token, and the one at the beginning points to itself as the `previous` token.
|
||||
So, for a correctly formed token stream (which we routinely assume will always
|
||||
be the case) neither `previous` nor `next` can ever return `null`. We can't
|
||||
express that in the type system because those fields will be `null` temporarily
|
||||
while the list is being built. As a result, the convention throughout the code
|
||||
base, is to suffix those two getters with a bang (`!`) everywhere they're
|
||||
invoked.
|
||||
|
||||
Tokens are typically accessed through the [AST](ast.md).
|
Loading…
Reference in a new issue