Documentation ¶
Overview ¶
Package parser is a parser for MiGo (mini-go calculus) types.
A MiGo type can be obtained from an io.Reader by calling the Parse function.
p := parser.Parse(strings.NewReader(" def main(): send ch; "))
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Parse ¶
Parse is the entry point to the migo type parser
Example ¶
This example demonstrates the use of the Parser. The output should be exactly the same as input (but pretty printed).
s := `def main.main(): let ch = newchan ch, 0; spawn main.sndr(ch); recv ch; def main.sndr(ch): send ch;` r := strings.NewReader(s) parsed, err := Parse(r) if err != nil { log.Fatal(err) } fmt.Println(parsed.String())
Output: def main.main(): let ch = newchan ch, 0; spawn main.sndr(ch); recv ch; def main.sndr(ch): send ch;
Types ¶
type ConstToken ¶
type ConstToken struct {
// contains filtered or unexported fields
}
ConstToken is a normal constant token.
func (*ConstToken) EndPos ¶
func (t *ConstToken) EndPos() TokenPos
EndPos returns ending position of token.
func (*ConstToken) StartPos ¶
func (t *ConstToken) StartPos() TokenPos
StartPos returns starting position of token.
type DigitsToken ¶
type DigitsToken struct {
// contains filtered or unexported fields
}
DigitsToken is a token with numeric value (Digits).
func (*DigitsToken) EndPos ¶
func (t *DigitsToken) EndPos() TokenPos
EndPos returns ending position of token.
func (*DigitsToken) StartPos ¶
func (t *DigitsToken) StartPos() TokenPos
StartPos returns starting position of token.
type IdentToken ¶
type IdentToken struct {
// contains filtered or unexported fields
}
IdentToken is a token with string value (Ident).
func (*IdentToken) EndPos ¶
func (t *IdentToken) EndPos() TokenPos
EndPos returns ending position of token.
func (*IdentToken) StartPos ¶
func (t *IdentToken) StartPos() TokenPos
StartPos returns starting position of token.
type Lexer ¶
type Lexer struct { Errors chan error // contains filtered or unexported fields }
Lexer for migo.
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner is a lexical scanner.
func NewScanner ¶
NewScanner returns a new instance of Scanner.