亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

目錄 搜尋
archive archive/tar archive/zip bufio bufio(緩存) builtin builtin(內(nèi)置包) bytes bytes(包字節(jié)) compress compress/bzip2(壓縮/bzip2) compress/flate(壓縮/flate) compress/gzip(壓縮/gzip) compress/lzw(壓縮/lzw) compress/zlib(壓縮/zlib) container container/heap(容器數(shù)據(jù)結(jié)構(gòu)heap) container/list(容器數(shù)據(jù)結(jié)構(gòu)list) container/ring(容器數(shù)據(jù)結(jié)構(gòu)ring) context context(上下文) crypto crypto(加密) crypto/aes(加密/aes) crypto/cipher(加密/cipher) crypto/des(加密/des) crypto/dsa(加密/dsa) crypto/ecdsa(加密/ecdsa) crypto/elliptic(加密/elliptic) crypto/hmac(加密/hmac) crypto/md5(加密/md5) crypto/rand(加密/rand) crypto/rc4(加密/rc4) crypto/rsa(加密/rsa) crypto/sha1(加密/sha1) crypto/sha256(加密/sha256) crypto/sha512(加密/sha512) crypto/subtle(加密/subtle) crypto/tls(加密/tls) crypto/x509(加密/x509) crypto/x509/pkix(加密/x509/pkix) database database/sql(數(shù)據(jù)庫(kù)/sql) database/sql/driver(數(shù)據(jù)庫(kù)/sql/driver) debug debug/dwarf(調(diào)試/dwarf) debug/elf(調(diào)試/elf) debug/gosym(調(diào)試/gosym) debug/macho(調(diào)試/macho) debug/pe(調(diào)試/pe) debug/plan9obj(調(diào)試/plan9obj) encoding encoding(編碼) encoding/ascii85(編碼/ascii85) encoding/asn1(編碼/asn1) encoding/base32(編碼/base32) encoding/base64(編碼/base64) encoding/binary(編碼/binary) encoding/csv(編碼/csv) encoding/gob(編碼/gob) encoding/hex(編碼/hex) encoding/json(編碼/json) encoding/pem(編碼/pem) encoding/xml(編碼/xml) errors errors(錯(cuò)誤) expvar expvar flag flag(命令行參數(shù)解析flag包) fmt fmt go go/ast(抽象語(yǔ)法樹(shù)) go/build go/constant(常量) go/doc(文檔) go/format(格式) go/importer go/parser go/printer go/scanner(掃描儀) go/token(令牌) go/types(類型) hash hash(散列) hash/adler32 hash/crc32 hash/crc64 hash/fnv html html html/template(模板) image image(圖像) image/color(顏色) image/color/palette(調(diào)色板) image/draw(繪圖) image/gif image/jpeg image/png index index/suffixarray io io io/ioutil log log log/syslog(日志系統(tǒng)) math math math/big math/big math/bits math/bits math/cmplx math/cmplx math/rand math/rand mime mime mime/multipart(多部分) mime/quotedprintable net net net/http net/http net/http/cgi net/http/cookiejar net/http/fcgi net/http/httptest net/http/httptrace net/http/httputil net/http/internal net/http/pprof net/mail net/mail net/rpc net/rpc net/rpc/jsonrpc net/smtp net/smtp net/textproto net/textproto net/url net/url os os os/exec os/signal os/user path path path/filepath(文件路徑) plugin plugin(插件) reflect reflect(反射) regexp regexp(正則表達(dá)式) regexp/syntax runtime runtime(運(yùn)行時(shí)) runtime/debug(調(diào)試) runtime/internal/sys runtime/pprof runtime/race(競(jìng)爭(zhēng)) runtime/trace(執(zhí)行追蹤器) sort sort(排序算法) strconv strconv(轉(zhuǎn)換) strings strings(字符串) sync sync(同步) sync/atomic(原子操作) syscall syscall(系統(tǒng)調(diào)用) testing testing(測(cè)試) testing/iotest testing/quick text text/scanner(掃描文本) text/tabwriter text/template(定義模板) text/template/parse time time(時(shí)間戳) unicode unicode unicode/utf16 unicode/utf8 unsafe unsafe
文字

  • import "go/token"

  • Overview

  • Index

概觀

Package標(biāo)記定義代表Go編程語(yǔ)言的詞法標(biāo)記的常量和標(biāo)記(打印,謂詞)的基本操作。

索引

  • Constants

  • type File

  • func (f *File) AddLine(offset int)

  • func (f *File) AddLineInfo(offset int, filename string, line int)

  • func (f *File) Base() int

  • func (f *File) Line(p Pos) int

  • func (f *File) LineCount() int

  • func (f *File) MergeLine(line int)

  • func (f *File) Name() string

  • func (f *File) Offset(p Pos) int

  • func (f *File) Pos(offset int) Pos

  • func (f *File) Position(p Pos) (pos Position)

  • func (f *File) PositionFor(p Pos, adjusted bool) (pos Position)

  • func (f *File) SetLines(lines []int) bool

  • func (f *File) SetLinesForContent(content []byte)

  • func (f *File) Size() int

  • type FileSet

  • func NewFileSet() *FileSet

  • func (s *FileSet) AddFile(filename string, base, size int) *File

  • func (s *FileSet) Base() int

  • func (s *FileSet) File(p Pos) (f *File)

  • func (s *FileSet) Iterate(f func(*File) bool)

  • func (s *FileSet) Position(p Pos) (pos Position)

  • func (s *FileSet) PositionFor(p Pos, adjusted bool) (pos Position)

  • func (s *FileSet) Read(decode func(interface{}) error) error

  • func (s *FileSet) Write(encode func(interface{}) error) error

  • type Pos

  • func (p Pos) IsValid() bool

  • type Position

  • func (pos *Position) IsValid() bool

  • func (pos Position) String() string

  • type Token

  • func Lookup(ident string) Token

  • func (tok Token) IsKeyword() bool

  • func (tok Token) IsLiteral() bool

  • func (tok Token) IsOperator() bool

  • func (op Token) Precedence() int

  • func (tok Token) String() string

包文件

position.go serialize.go token.go

常量

一組基于優(yōu)先級(jí)的表達(dá)式分析的常量。非運(yùn)營(yíng)商的優(yōu)先級(jí)最低,其次是運(yùn)營(yíng)商從優(yōu)先級(jí)1開(kāi)始直到一元運(yùn)營(yíng)商。最高優(yōu)先級(jí)用作選擇器,索引和其他運(yùn)算符和分隔符令牌的“全部捕捉”優(yōu)先級(jí)。

const (
        LowestPrec  = 0 // non-operators
        UnaryPrec   = 6
        HighestPrec = 7)

type File

文件是屬于FileSet的文件的句柄。文件具有名稱,大小和行偏移量表。

type File struct {        // contains filtered or unexported fields}

func (*File) AddLine

func (f *File) AddLine(offset int)

AddLine為新行添加行偏移量。行偏移量必須大于前一行的偏移量并小于文件大小; 否則行偏移將被忽略。

func (*File) AddLineInfo

func (f *File) AddLineInfo(offset int, filename string, line int)

AddLineInfo為給定的文件偏移量添加替代文件和行號(hào)信息。偏移量必須大于先前添加的替代線信息的偏移量并小于文件大小; 否則信息被忽略。

AddLineInfo通常用于注冊(cè)//行文件名的替代位置信息:源文件中的行注釋。

func (*File) Base

func (f *File) Base() int

Base返回使用AddFile注冊(cè)的文件f的基本偏移量。

func (*File) Line

func (f *File) Line(p Pos) int

Line返回給定文件位置p的行號(hào); p必須是該文件或NoPos中的Pos值。

func (*File) LineCount

func (f *File) LineCount() int

LineCount返回文件f中的行數(shù)。

func (*File) MergeLine

func (f *File) MergeLine(line int)

MergeLine將一行與以下行合并。它類似于用一個(gè)空格替換行尾的換行符(以不改變剩余的偏移量)。要獲得行號(hào),請(qǐng)參考例如Position.Line。如果給出無(wú)效的行號(hào),MergeLine將會(huì)發(fā)生混亂。

func (*File) Name

func (f *File) Name() string

Name返回使用AddFile注冊(cè)的文件f的文件名。

func (*File) Offset

func (f *File) Offset(p Pos) int

偏移返回給定文件位置p的偏移量; p必須是該文件中的有效Pos值。f.Offset(f.Pos(offset))== offset。

func (*File) Pos

func (f *File) Pos(offset int) Pos

Pos返回給定文件偏移量的Pos值; 偏移量必須<= f.Size()。f.Pos(f.Offset(p))== p。

func (*File) Position

func (f *File) Position(p Pos) (pos Position)

位置返回給定文件位置p的位置值。調(diào)用f.Position(p)等效于調(diào)用f.PositionFor(p,true)。

func (*File) PositionFor

func (f *File) PositionFor(p Pos, adjusted bool) (pos Position)

PositionFor返回給定文件位置p的Position值。如果調(diào)整已設(shè)置,則可以通過(guò)改變位置//行注釋來(lái)調(diào)整位置; 否則這些評(píng)論被忽略。p必須是f或NoPos中的Pos值。

func (*File) SetLines

func (f *File) SetLines(lines []int) bool

SetLines設(shè)置文件的行偏移量并報(bào)告它是否成功。線偏移量是每行第一個(gè)字符的偏移量; 例如對(duì)于內(nèi)容“ab \ nc \ n”,行偏移是{0,3}。一個(gè)空文件有一個(gè)空行偏移表。每行偏移量必須大于前一行的偏移量并小于文件大小; 否則SetLines失敗并返回false。在SetLines返回之后,調(diào)用者不得改變提供的切片。

func (*File) SetLinesForContent

func (f *File) SetLinesForContent(content []byte)

SetLinesForContent設(shè)置給定文件內(nèi)容的行偏移量。它忽略了改變位置的//行注釋。

func (*File) Size

func (f *File) Size() int

Size返回使用AddFile注冊(cè)的文件f的大小。

type FileSet

FileSet代表一組源文件。文件集的方法是同步的; 多個(gè)goroutines可以同時(shí)調(diào)用它們。

type FileSet struct {        // contains filtered or unexported fields}

func NewFileSet

func NewFileSet() *FileSet

NewFileSet創(chuàng)建一個(gè)新的文件集。

func (*FileSet) AddFile

func (s *FileSet) AddFile(filename string, base, size int) *File

AddFile將具有給定文件名,基礎(chǔ)偏移量和文件大小的新文件添加到文件集s并返回文件。多個(gè)文件可能具有相同的名稱?;酒撇坏眯∮贔ileSet的Base(),并且大小不能是負(fù)數(shù)。作為一種特殊情況,如果提供了否定基數(shù),則將使用FileSet的Base()的當(dāng)前值。

添加文件將把文件集的Base()值設(shè)置為base + size + 1作為下一個(gè)文件的最小基值。以下關(guān)系存在于給定文件偏移量的Pos值p之間:

int(p) = base + offs

在范圍0,大小和因此在范圍基地,基地+大小的偏差。為了方便起見(jiàn),F(xiàn)ile.Pos可用于從文件偏移量創(chuàng)建文件特定的位置值。

func (*FileSet) Base

func (s *FileSet) Base() int

Base返回添加下一個(gè)文件時(shí)必須提供給AddFile的最小基本偏移量。

func (*FileSet) File

func (s *FileSet) File(p Pos) (f *File)

文件返回包含位置p的文件。如果沒(méi)有找到這樣的文件(例如p == NoPos),結(jié)果為零。

func (*FileSet) Iterate

func (s *FileSet) Iterate(f func(*File) bool)

按照添加的順序迭代調(diào)用f來(lái)獲取文件集中的文件,直到f返回false。

func (*FileSet) Position

func (s *FileSet) Position(p Pos) (pos Position)

位置將文件集中的Pos p轉(zhuǎn)換為Position值。調(diào)用s.Position(p)等效于調(diào)用s.PositionFor(p,true)。

func (*FileSet) PositionFor

func (s *FileSet) PositionFor(p Pos, adjusted bool) (pos Position)

PositionFor將文件集中的Pos p轉(zhuǎn)換為Position值。如果調(diào)整已設(shè)置,則可以通過(guò)改變位置//行注釋來(lái)調(diào)整位置; 否則這些評(píng)論被忽略。p必須是s或NoPos中的Pos值。

func (*FileSet) Read

func (s *FileSet) Read(decode func(interface{}) error) error

讀取調(diào)用解碼以將一個(gè)文件集反序列化為s; s不能為零。

func (*FileSet) Write

func (s *FileSet) Write(encode func(interface{}) error) error

編寫調(diào)用編碼以序列化文件集。

type Pos

Pos是文件集中源位置的緊湊編碼。它可以轉(zhuǎn)換為一個(gè)更方便,但更大的表示的位置。

給定文件的Pos值是基本范圍base + size中的數(shù)字,其中base和size是通過(guò)AddFile將文件添加到文件集時(shí)指定的。

要為特定源偏移量創(chuàng)建Pos值(以字節(jié)為單位),請(qǐng)首先使用FileSet.AddFile將相應(yīng)文件添加到當(dāng)前文件集,然后調(diào)用該文件的File.Pos(offset)。給定特定文件集fset的Pos值p,通過(guò)調(diào)用fset.Position(p)獲得相應(yīng)的Position值。

可以將Pos值直接與通常的比較運(yùn)算符進(jìn)行比較:如果兩個(gè)Pos值p和q在同一個(gè)文件中,則比較p和q就相當(dāng)于比較各個(gè)源文件偏移量。如果p和q在不同的文件中,如果p所隱含的文件被添加到q所隱含的文件之前的相應(yīng)文件集中,則p <q為真。

type Pos int

Pos的零值是NoPos; 沒(méi)有與之關(guān)聯(lián)的文件和行信息,并且NoPos.IsValid()為false。NoPos總是小于任何其他Pos值。NoPos的相應(yīng)位置值是位置的零值。

const NoPos Pos = 0

func (Pos) IsValid

func (p Pos) IsValid() bool

IsValid報(bào)告該位置是否有效。

type Position

位置描述包括文件,行和列位置的任意源位置。如果行號(hào)> 0,則位置有效。

type Position struct {
        Filename string // filename, if any
        Offset   int    // offset, starting at 0
        Line     int    // line number, starting at 1
        Column   int    // column number, starting at 1 (byte count)}

func (*Position) IsValid

func (pos *Position) IsValid() bool

IsValid報(bào)告該位置是否有效。

func (Position) String

func (pos Position) String() string

字符串以幾種形式之一返回一個(gè)字符串:

file:line:column    valid position with file name
line:column         valid position without file name
file                invalid position with file name-                   invalid position without file name

type Token

令牌是Go編程語(yǔ)言的一組詞匯標(biāo)記。

type Token int

令牌列表。

const (        // Special tokens
        ILLEGAL Token = iota
        EOF
        COMMENT        // Identifiers and basic type literals        // (these tokens stand for classes of literals)
        IDENT  // main
        INT    // 12345
        FLOAT  // 123.45
        IMAG   // 123.45i
        CHAR   // 'a'
        STRING // "abc"        // Operators and delimiters
        ADD // +
        SUB // -
        MUL // *
        QUO // /
        REM // %

        AND     // &
        OR      // |
        XOR     // ^
        SHL     // <<
        SHR     // >>
        AND_NOT // &^

        ADD_ASSIGN // +=
        SUB_ASSIGN // -=
        MUL_ASSIGN // *=
        QUO_ASSIGN // /=
        REM_ASSIGN // %=

        AND_ASSIGN     // &=
        OR_ASSIGN      // |=
        XOR_ASSIGN     // ^=
        SHL_ASSIGN     // <<=
        SHR_ASSIGN     // >>=
        AND_NOT_ASSIGN // &^=

        LAND  // &&
        LOR   // ||
        ARROW // <-
        INC   // ++
        DEC   // --

        EQL    // ==
        LSS    // <
        GTR    // >
        ASSIGN // =
        NOT    // !

        NEQ      // !=
        LEQ      // <=
        GEQ      // >=
        DEFINE   // :=
        ELLIPSIS // ...

        LPAREN // (
        LBRACK // [
        LBRACE // {
        COMMA  // ,
        PERIOD // .

        RPAREN    // )
        RBRACK    // ]
        RBRACE    // }
        SEMICOLON // ;
        COLON     // :        // Keywords
        BREAK
        CASE
        CHAN
        CONST
        CONTINUE

        DEFAULT
        DEFER
        ELSE
        FALLTHROUGH
        FOR

        FUNC
        GO
        GOTO
        IF
        IMPORT

        INTERFACE        MAP
        PACKAGE
        RANGE
        RETURN

        SELECT
        STRUCT
        SWITCH
        TYPE
        VAR)

func Lookup

func Lookup(ident string) Token

Lookup會(huì)將標(biāo)識(shí)符映射到其關(guān)鍵字標(biāo)記或IDENT(如果不是關(guān)鍵字)。

func (Token) IsKeyword

func (tok Token) IsKeyword() bool

IsKeyword對(duì)與關(guān)鍵字相對(duì)應(yīng)的標(biāo)記返回true; 否則返回false。

func (Token) IsLiteral

func (tok Token) IsLiteral() bool

對(duì)于與標(biāo)識(shí)符和基本類型文字相對(duì)應(yīng)的標(biāo)記,IsLiteral返回true; 否則返回false。

func (Token) IsOperator

func (tok Token) IsOperator() bool

IsOperator對(duì)運(yùn)算符和分隔符對(duì)應(yīng)的令牌返回true; 否則返回false。

func (Token) Precedence

func (op Token) Precedence() int

優(yōu)先級(jí)返回二元運(yùn)算符op的運(yùn)算符優(yōu)先級(jí)。如果op不是二元運(yùn)算符,則結(jié)果為L(zhǎng)owestPrecedence。

func (Token) String

func (tok Token) String() string

字符串返回對(duì)應(yīng)于令牌tok的字符串。對(duì)于運(yùn)算符,分隔符和關(guān)鍵字,字符串是實(shí)際的令牌字符序列(例如,對(duì)于令牌ADD,字符串是“+”)。對(duì)于所有其他標(biāo)記,字符串對(duì)應(yīng)于標(biāo)記常量名稱(例如對(duì)于標(biāo)記IDENT,字符串是“IDENT”)。

上一篇: 下一篇: