Exemple #1
0
func parseFile(filename string) {
	p := noder{baseline: lexlineno}
	file, err := syntax.ReadFile(filename, p.error, p.pragma, 0)
	if err != nil {
		Fatalf("syntax.ReadFile %s: %v", filename, err)
	}

	p.file(file)

	if !imported_unsafe {
		for _, x := range p.linknames {
			p.error(0, x, "//go:linkname only allowed in Go files that import \"unsafe\"")
		}
	}

	if nsyntaxerrors == 0 {
		testdclstack()
	}
}
Exemple #2
0
func parseFile(filename string) {
	errh := func(_, line int, msg string) {
		yyerrorl(lexlineno+int32(line)-1, "%s", msg)
	}

	file, err := syntax.ReadFile(filename, errh, 0)
	if err != nil {
		Fatalf("syntax.ReadFile %s: %v", filename, err)
	}

	p := noder{pragmas: file.Pragmas}

	p.lineno(file.PkgName)
	mkpackage(file.PkgName.Value)

	xtop = append(xtop, p.decls(file.DeclList, true)...)
	p.globalPragmas()
	lexlineno += p.maxline

	if nsyntaxerrors == 0 {
		testdclstack()
	}
}