forked from astaxie/gopkg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
42c5677
commit e523a50
Showing
12 changed files
with
162 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# 包名 | ||
|
||
函数列表 | ||
包列表 | ||
|
||
- xxx1 | ||
- xxx2 | ||
- [text/scanner](scanner) | ||
- xxx2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const ( | ||
ScanIdents = 1 << -Ident | ||
ScanInts = 1 << -Int | ||
ScanFloats = 1 << -Float // includes Ints | ||
ScanChars = 1 << -Char | ||
ScanStrings = 1 << -String | ||
ScanRawStrings = 1 << -RawString | ||
ScanComments = 1 << -Comment | ||
SkipComments = 1 << -skipComment // if set with ScanComments, comments become white space | ||
GoTokens = ScanIdents | ScanFloats | ScanChars | ScanStrings | ScanRawStrings | ScanComments | SkipComments | ||
) | ||
|
||
用于控制词法单元识别的预定义模式位。比如,通过以下模式位设置,可以配置一个只识别(Go)标识符、整型、并且忽略注释的词法解析器: | ||
|
||
ScanIdents | ScanInts | SkipComments | ||
|
||
const ( | ||
EOF = -(iota + 1) | ||
Ident | ||
Int | ||
Float | ||
Char | ||
String | ||
RawString | ||
Comment | ||
) | ||
|
||
通过Scan方法可以获取的词法单元,此外还可以获取Unicode字符。 | ||
|
||
const GoWhitespace = 1<<'\t' | 1<<'\n' | 1<<'\r' | 1<<' ' | ||
|
||
GoWhitespace,Scanner的空白字符的默认值。 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
type Position struct { | ||
Filename string // 文件名,可能为空 | ||
Offset int // 位移,从0计 | ||
Line int // 行数,从1计 | ||
Column int // 列数,从1计(按字符计算) | ||
} | ||
|
||
Position用来表示源中的位置。行数Line > 0的情况下,Position合法。 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters