Documentation ¶
Overview ¶
Package tl implements Telegram's TL(Type Language) lexer and parser. It takes a []byte as source which can be tokenized through the scanner and then they fed to the parser. The output is an abstract syntax tree (AST) representing the TL program.
Index ¶
- type Arg
- type BareType
- type BoxedTypeIdent
- type BuiltinCombDecl
- type CombDecl
- type Combinator
- type CombinatorId
- type ConstrDecl
- type Declaration
- type Expr
- type FullCombinatorId
- type FuncDecl
- type Ident
- type Item
- type Node
- type OptionalArg
- type Parser
- type Program
- type ResultType
- type Scanner
- type Token
- type TypeIdent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BoxedTypeIdent ¶
type BoxedTypeIdent struct {
Name string
}
type BuiltinCombDecl ¶
type BuiltinCombDecl struct { Id FullCombinatorId Result BoxedTypeIdent }
A declaration is represented by one of the following declaration nodes.
type CombDecl ¶
type CombDecl struct { Id FullCombinatorId OptArgs []OptionalArg Args []Arg Result ResultType }
A declaration is represented by one of the following declaration nodes.
type Combinator ¶
Combinator represents a constructor, function or a built-in combinator whose combinator-name can be computed.
type CombinatorId ¶
type CombinatorId struct {
Id Ident
}
type ConstrDecl ¶
type ConstrDecl struct{}
A declaration is represented by one of the following declaration nodes.
func (ConstrDecl) Name ¶
func (ConstrDecl) Name()
combinatorNode implementations for combinator nodes.
type Declaration ¶
type Declaration interface { Node // contains filtered or unexported methods }
Declaration represents a constructor or function declaration. All declaration nodes implement the Declaration interface.
type FullCombinatorId ¶
type FullCombinatorId struct {
Id Ident
}
type FuncDecl ¶
type FuncDecl struct{}
A declaration is represented by one of the following declaration nodes.
type Item ¶
type Item int
Item represents a lexical token type.
const ( ItemIllegal Item = iota ItemWhitespace ItemEOF ItemUnderscore // _ ItemColon // : ItemSemicolon // ; ItemOpenPar // ( ItemClosePar // ) ItemOpenBracket // [ ItemCloseBracket // ] ItemOpenBrace // { ItemCloseBrace // } ItemLeftAngle // < ItemRightAngle // > ItemTripleMinus // --- ItemEquals // = ItemHash // # ItemExclMark // ! ItemQuestionMark // ? ItemPercent // % ItemPlus // + ItemComma // , ItemDot // . ItemAsterisk // * ItemNatConst // 4, 42, 421 // LowerIdent represents lc-ident, lc-ident-ns and lc-ident-full ItemLowerIdent // user | user#decafbad | users.user | users.user#decafbad // UpperIdent represents uc-ident, uc-ident-ns ItemUpperIdent // User | group.User ItemFinal // Final ItemNew // New ItemEmpty // Empty )
List of tokens - https://core.telegram.org/mtproto/TL-formal#tokens
type Node ¶
type Node interface {
// contains filtered or unexported methods
}
Node represents a node in abstract syntax tree.
type OptionalArg ¶
type OptionalArg struct{}
type Parser ¶
type Parser struct { Trace bool // parsing mode // contains filtered or unexported fields }
Parser holds the parser's internal state while consuming a given token.
type Program ¶
type Program struct { Constructors []ConstrDecl // Optional Functions []FuncDecl Types []ConstrDecl }
Program represents a TL program.
https://core.telegram.org/mtproto/TL-formal
type ResultType ¶
type ResultType struct{}
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner implements a TL (Type Language) lexer.
func NewScanner ¶
NewScanner returns a Scanner which tokenizes a TL program