Documentation ¶
Overview ¶
Package parser translates the linear stream of tokens into ast structures based on the syntax of the ok language.
Index ¶
- type Errors
- type Parser
- func (parser *Parser) Comments() []*ast.Comment
- func (parser *Parser) Errors() Errors
- func (parser *Parser) Funcs() map[string]*ast.Func
- func (parser *Parser) Imports() map[string]string
- func (parser *Parser) Package(packageAlias string) *ast.Func
- func (parser *Parser) ParseDirectory(dirPath string, includeTests bool)
- func (parser *Parser) ParseFile(fileName string)
- func (parser *Parser) ParseString(s string, fileName string)
- func (parser *Parser) ResolveType(node ast.Node, typ *types.Type, registry types.Registry, ...) (*types.Type, error)
- func (parser *Parser) ResolveTypes(registry types.Registry, imports map[string]*types.Type) error
- func (parser *Parser) SortedFuncNames() []string
- func (parser *Parser) Tests() []*ast.Test
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Parser ¶
type Parser struct { // Constants are variables defined at the package level. They cannot be // modified and only allow literals for values. // // TODO(elliot): We should allow for expressions that can be resolved at // compile time, such as "3600 * 24". Constants map[string]*ast.Literal // contains filtered or unexported fields }
func (*Parser) Comments ¶ added in v0.19.4
Comments returns all comments collected from parsing all inputs.
func (*Parser) ParseDirectory ¶ added in v0.19.4
ParseDirectory will read and parse all ".ok" files in a directory (not recursive). This is analogous to parsing a package. If any of the files (or the directory itself) cannot be read the error will be appended to the parser errors.
If includeTests = true, then ".okt" files will also be included.
func (*Parser) ParseFile ¶ added in v0.19.4
ParseFile will read and parse the file. If the file cannot be read the error will be appended to the parser errors.
func (*Parser) ParseString ¶ added in v0.19.4
ParseString parses source code from a string. The fileName is used in error messages, the file does not have to exist.
func (*Parser) ResolveType ¶ added in v0.24.0
func (*Parser) ResolveTypes ¶ added in v0.24.0
func (parser *Parser) ResolveTypes( registry types.Registry, imports map[string]*types.Type, ) error
ResolveTypes is a necessary part between the parsing finishing and the compiler starting. It is the job of this process to translate all the keywords that represent types (that would appear in argument types, return types, etc) into the actual types within this package.
Types referring to an external types (ie. "foo.Bar") are also resolved here, and all imports are expected to be provided to this function.
func (*Parser) SortedFuncNames ¶ added in v0.24.0
Source Files ¶
- array.go
- assert.go
- assign.go
- assignable.go
- block.go
- call.go
- consume.go
- doc.go
- error.go
- error_scope.go
- errors.go
- expr.go
- for.go
- func.go
- group.go
- identifier.go
- if.go
- import.go
- interpolate.go
- key_value.go
- literal.go
- map.go
- parse.go
- parser.go
- raise.go
- return.go
- statement.go
- switch.go
- test.go
- type.go
- types.go
- util.go