MCPcopy Index your code
hub / github.com/google/mangle / Unit

Function Unit

parse/parse.go:122–141  ·  view source on GitHub ↗

Unit parses a source unit (clauses and decls).

(reader io.Reader)

Source from the content-addressed store, hash-verified

120
121// Unit parses a source unit (clauses and decls).
122func Unit(reader io.Reader) (SourceUnit, error) {
123 bytes, err := io.ReadAll(reader)
124 if err != nil {
125 return SourceUnit{}, err
126 }
127 p, err := newParser(string(bytes))
128 if err != nil {
129 return SourceUnit{}, err
130 }
131 defer p.reset()
132 tree := p.parser.Start_()
133 if err := p.error(); err != nil {
134 return SourceUnit{}, err
135 }
136 sourceUnit := p.Visit(tree)
137 if err := p.error(); err != nil {
138 return SourceUnit{}, err
139 }
140 return sourceUnit.(SourceUnit), nil
141}
142
143func (p *Parser) error() error {
144 if len(p.errors.errors) == 0 {

Callers 15

LoadMethod · 0.92
DefineMethod · 0.92
unitFunction · 0.92
TestCasesFunction · 0.92
TestAnalyzeTemporalFunction · 0.92

Calls 5

newParserFunction · 0.85
resetMethod · 0.80
Start_Method · 0.80
errorMethod · 0.80
VisitMethod · 0.80