Esempio n. 1
0
// Parse creates a new parser for the input string.
// It uses lex to tokenize the input
func Parse(name, input string) *Parser {
	l := lex.Lex(name, input)
	p := &Parser{
		name:     name,
		input:    input,
		pos:      -1,
		Lexer:    l,
		File:     ast.NewFile(),
		topScope: ast.NewScope(nil),
		pDepth:   new(ParenDepth),
	}
	p.run()
	return p
}
Esempio n. 2
0
func (p *Parser) openScope() {
	p.topScope = ast.NewScope(p.topScope)
}