ee43212da4
This removes some unused dependencies that I know we plan to re-add later, but this makes for a clean `godep save` for now.
31 lines
633 B
Go
31 lines
633 B
Go
package hil
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/hashicorp/hil/ast"
|
|
)
|
|
|
|
var parserLock sync.Mutex
|
|
var parserResult ast.Node
|
|
|
|
// Parse parses the given program and returns an executable AST tree.
|
|
func Parse(v string) (ast.Node, error) {
|
|
// Unfortunately due to the way that goyacc generated parsers are
|
|
// formatted, we can only do a single parse at a time without a lot
|
|
// of extra work. In the future we can remove this limitation.
|
|
parserLock.Lock()
|
|
defer parserLock.Unlock()
|
|
|
|
// Reset our globals
|
|
parserResult = nil
|
|
|
|
// Create the lexer
|
|
lex := &parserLex{Input: v}
|
|
|
|
// Parse!
|
|
parserParse(lex)
|
|
|
|
return parserResult, lex.Err
|
|
}
|