• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang log.Errorln函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/ark-lang/ark/src/util/log.Errorln函数的典型用法代码示例。如果您正苦于以下问题:Golang Errorln函数的具体用法?Golang Errorln怎么用?Golang Errorln使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Errorln函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: parseFile

func (v *Context) parseFile(path string, module *ast.Module) {
	// Read
	sourcefile, err := lexer.NewSourcefile(path)
	if err != nil {
		setupErr("%s", err.Error())
	}

	// Lex
	sourcefile.Tokens = lexer.Lex(sourcefile)

	// Parse
	parsedFile, deps := parser.Parse(sourcefile)
	module.Trees = append(module.Trees, parsedFile)

	// Add dependencies to parse array
	for _, dep := range deps {
		depname := ast.NewModuleName(dep)
		v.modulesToRead = append(v.modulesToRead, depname)
		v.depGraph.AddDependency(module.Name, depname)

		if _, _, err := v.findModuleDir(depname.ToPath()); err != nil {
			log.Errorln("main", "%s [%s:%d:%d] Couldn't find module `%s`", util.Red("error:"),
				dep.Where().Filename, dep.Where().StartLine, dep.Where().EndLine,
				depname.String())
			log.Errorln("main", "%s", sourcefile.MarkSpan(dep.Where()))
			os.Exit(1)
		}
	}
}
开发者ID:kiljacken,项目名称:ark,代码行数:29,代码来源:main.go


示例2: TypeOfNameNode

func (v *NameMap) TypeOfNameNode(name *NameNode) NodeType {
	mod := v
	typ := NODE_MODULE
	for _, modName := range name.Modules {
		if typ == NODE_MODULE {
			typ = mod.typeOf(modName)
			if typ == NODE_MODULE {
				mod = mod.module(modName)
				if mod == nil {
					return NODE_UNKOWN
				}
			}
		} else {
			startPos := modName.Where.Start()
			log.Errorln("constructor", "[%s:%d:%d] Invalid use of `::`. `%s` is not a module",
				startPos.Filename, startPos.Line, startPos.Char, modName.Value)
			log.Error("constructor", v.tree.Source.MarkSpan(modName.Where))
		}
	}

	if typ == NODE_ENUM {
		return NODE_ENUM_MEMBER
	} else if typ == NODE_STRUCT {
		return NODE_STRUCT_STATIC
	}

	typ = mod.typeOf(name.Name)
	if typ == NODE_UNKOWN {
		startPos := name.Name.Where.Start()
		log.Errorln("constructor", "[%s:%d:%d] Undeclared name `%s`",
			startPos.Filename, startPos.Line, startPos.Char, name.Name.Value)
		log.Error("constructor", v.tree.Source.MarkSpan(name.Name.Where))
	}
	return typ
}
开发者ID:dansawkins,项目名称:ark,代码行数:35,代码来源:name_pass.go


示例3: Visit

func (v *RecursiveDefinitionCheck) Visit(s *SemanticAnalyzer, n parser.Node) {
	var typ parser.Type

	if typeDecl, ok := n.(*parser.TypeDecl); ok {
		actualType := typeDecl.NamedType.ActualType()
		switch actualType.(type) {
		case *parser.EnumType:
			typ = actualType.(*parser.EnumType)

		case *parser.StructType:
			typ = actualType.(*parser.StructType)

			// TODO: Check tuple types once we add named types for everything

		default:
			return
		}
	}

	if ok, path := isTypeRecursive(typ); ok {
		s.Err(n, "Encountered recursive type definition")

		log.Errorln("semantic", "Path taken:")
		for _, typ := range path {
			log.Error("semantic", typ.TypeName())
			log.Error("semantic", " <- ")
		}
		log.Error("semantic", "%s\n\n", typ.TypeName())
	}

}
开发者ID:dansawkins,项目名称:ark,代码行数:31,代码来源:recursive.go


示例4: errPos

func (v *lexer) errPos(pos Position, err string, stuff ...interface{}) {
	log.Errorln("lexer", util.TEXT_RED+util.TEXT_BOLD+"error:"+util.TEXT_RESET+" [%s:%d:%d] %s",
		pos.Filename, pos.Line, pos.Char, fmt.Sprintf(err, stuff...))

	log.Error("lexer", v.input.MarkPos(pos))

	os.Exit(1)
}
开发者ID:IanMurray,项目名称:ark,代码行数:8,代码来源:lexer.go


示例5: ExtractTypeVariable

func ExtractTypeVariable(pattern Type, value Type) map[string]Type {
	/*
		Pointer($T), Pointer(int) -> {$T: int}
		Arbitrary depth type => Stack containing breadth first traversal
	*/
	res := make(map[string]Type)

	var (
		ps []Type
		vs []Type
	)
	ps = append(ps, pattern)
	vs = append(vs, value)

	for i := 0; i < len(ps); i++ {
		ppart := ps[i]
		vpart := vs[i]
		log.Debugln("resovle", "\nP = `%s`, V = `%s`", ppart.TypeName(), vpart.TypeName())

		ps = AddChildren(ppart, ps)
		vs = AddChildren(vpart, vs)

		if vari, ok := ppart.(ParameterType); ok {
			log.Debugln("resolve", "P was variable (Name: %s)", vari.Name)
			res[vari.Name] = vpart
			continue
		}

		switch ppart.(type) {
		case PrimitiveType, *NamedType:
			if !ppart.Equals(vpart) {
				log.Errorln("resolve", "%s != %s", ppart.TypeName(), vpart.TypeName())
				panic("Part of type did not match pattern")
			}

		default:
			if reflect.TypeOf(ppart) != reflect.TypeOf(vpart) {
				log.Errorln("resolve", "%T != %T", ppart, vpart)
				panic("Part of type did not match pattern")
			}
		}
	}

	return res
}
开发者ID:IanMurray,项目名称:ark,代码行数:45,代码来源:resolve.go


示例6: errPos

func (v *Constructor) errPos(pos lexer.Position, err string, stuff ...interface{}) {
	log.Errorln("constructor",
		util.TEXT_RED+util.TEXT_BOLD+"Constructor error:"+util.TEXT_RESET+" [%s:%d:%d] %s",
		pos.Filename, pos.Line, pos.Char,
		fmt.Sprintf(err, stuff...))

	log.Error("constructor", v.tree.Source.MarkPos(pos))

	os.Exit(util.EXIT_FAILURE_CONSTRUCTOR)
}
开发者ID:gitter-badger,项目名称:ark,代码行数:10,代码来源:constructor.go


示例7: Err

func (v *SemanticAnalyzer) Err(thing parser.Locatable, err string, stuff ...interface{}) {
	pos := thing.Pos()

	log.Error("semantic", util.TEXT_RED+util.TEXT_BOLD+"error:"+util.TEXT_RESET+" [%s:%d:%d] %s\n",
		pos.Filename, pos.Line, pos.Char, fmt.Sprintf(err, stuff...))

	log.Errorln("semantic", v.Module.File.MarkPos(pos))

	v.shouldExit = true
}
开发者ID:dansawkins,项目名称:ark,代码行数:10,代码来源:semantic.go


示例8: TypeOf

func (v *NameMap) TypeOf(name LocatedString) NodeType {
	typ := v.typeOf(name)
	if typ == NODE_UNKOWN {
		startPos := name.Where.Start()
		log.Errorln("constructor", "[%s:%d:%d] Undeclared name `%s`",
			startPos.Filename, startPos.Line, startPos.Char, name.Value)
		log.Error("constructor", v.tree.Source.MarkSpan(name.Where))
	}
	return typ
}
开发者ID:dansawkins,项目名称:ark,代码行数:10,代码来源:name_pass.go


示例9: errSpan

func (v *Constructor) errSpan(pos lexer.Span, err string, stuff ...interface{}) {
	log.Errorln("constructor",
		util.TEXT_RED+util.TEXT_BOLD+"error:"+util.TEXT_RESET+" [%s:%d:%d] %s",
		pos.Filename, pos.StartLine, pos.StartChar,
		fmt.Sprintf(err, stuff...))

	log.Error("constructor", v.curTree.Source.MarkSpan(pos))

	os.Exit(util.EXIT_FAILURE_CONSTRUCTOR)
}
开发者ID:kiljacken,项目名称:ark,代码行数:10,代码来源:constructor.go


示例10: Module

func (v *NameMap) Module(name LocatedString) *NameMap {
	mod := v.module(name)
	if mod == nil {
		startPos := name.Where.Start()
		log.Errorln("constructor", "[%s:%d:%d] Unknown module `%s`",
			startPos.Filename, startPos.Line, startPos.Char, name.Value)
		log.Error("constructor", v.tree.Source.MarkSpan(name.Where))
	}
	return mod
}
开发者ID:dansawkins,项目名称:ark,代码行数:10,代码来源:name_pass.go


示例11: errPosSpecific

func (v *parser) errPosSpecific(pos lexer.Position, err string, stuff ...interface{}) {
	v.dumpRules()
	log.Errorln("parser",
		util.TEXT_RED+util.TEXT_BOLD+"error:"+util.TEXT_RESET+" [%s:%d:%d] %s",
		pos.Filename, pos.Line, pos.Char,
		fmt.Sprintf(err, stuff...))

	log.Error("parser", v.input.MarkPos(pos))

	os.Exit(util.EXIT_FAILURE_PARSE)
}
开发者ID:IanMurray,项目名称:ark,代码行数:11,代码来源:parser.go


示例12: errTokenSpecific

func (v *parser) errTokenSpecific(tok *lexer.Token, err string, stuff ...interface{}) {
	v.dumpRules()
	log.Errorln("parser",
		util.TEXT_RED+util.TEXT_BOLD+"error:"+util.TEXT_RESET+" [%s:%d:%d] %s",
		tok.Where.Filename, tok.Where.StartLine, tok.Where.StartChar,
		fmt.Sprintf(err, stuff...))

	log.Error("parser", v.input.MarkSpan(tok.Where))

	os.Exit(util.EXIT_FAILURE_PARSE)
}
开发者ID:IanMurray,项目名称:ark,代码行数:11,代码来源:parser.go


示例13: Visit

func (v *RecursiveDefinitionCheck) Visit(s *SemanticAnalyzer, n ast.Node) {
	if typeDecl, ok := n.(*ast.TypeDecl); ok {
		typ := typeDecl.NamedType
		if ok, path := isTypeRecursive(typ); ok {
			s.Err(n, "Encountered recursive type definition")

			log.Errorln("semantic", "Path taken:")
			for _, typ := range path {
				log.Error("semantic", typ.TypeName())
				log.Error("semantic", " <- ")
			}
			log.Error("semantic", "%s\n\n", typ.TypeName())
		}
	}
}
开发者ID:kiljacken,项目名称:ark,代码行数:15,代码来源:recursive.go


示例14: parseFiles

func (v *Context) parseFiles() {
	if strings.HasSuffix(v.Input, ".ark") {
		// Handle the special case of a single .ark file
		modname := &ast.ModuleName{Parts: []string{"__main"}}
		module := &ast.Module{
			Name:    modname,
			Dirpath: "",
		}
		v.moduleLookup.Create(modname).Module = module

		v.parseFile(v.Input, module)

		v.modules = append(v.modules, module)
	} else {
		if strings.ContainsAny(v.Input, `\/. `) {
			setupErr("Invalid module name: %s", v.Input)
		}

		modname := &ast.ModuleName{Parts: strings.Split(v.Input, "::")}
		v.modulesToRead = append(v.modulesToRead, modname)
	}

	log.Timed("read/lex/parse phase", "", func() {
		for i := 0; i < len(v.modulesToRead); i++ {
			modname := v.
				modulesToRead[i]

			// Skip already loaded modules
			if _, err := v.moduleLookup.Get(modname); err == nil {
				continue
			}

			fi, dirpath, err := v.findModuleDir(modname.ToPath())
			if err != nil {
				setupErr("Couldn't find module `%s`: %s", modname, err)
			}

			if !fi.IsDir() {
				setupErr("Expected path `%s` to be directory, was file.", dirpath)
			}

			module := &ast.Module{
				Name:    modname,
				Dirpath: dirpath,
			}
			v.moduleLookup.Create(modname).Module = module

			// Check module children
			childFiles, err := ioutil.ReadDir(dirpath)
			if err != nil {
				setupErr("%s", err.Error())
			}

			for _, childFile := range childFiles {
				if strings.HasPrefix(childFile.Name(), ".") || !strings.HasSuffix(childFile.Name(), ".ark") {
					continue
				}

				actualFile := filepath.Join(dirpath, childFile.Name())
				v.parseFile(actualFile, module)
			}

			v.modules = append(v.modules, module)
		}
	})

	// Check for cyclic dependencies (in modules)
	log.Timed("cyclic dependency check", "", func() {
		errs := v.depGraph.DetectCycles()
		if len(errs) > 0 {
			log.Error("main", "%s: Encountered cyclic dependency between: ", util.Bold(util.Red("error")))
			for _, cycle := range errs {
				log.Error("main", "%s", cycle)
			}
			log.Errorln("main", "")
			os.Exit(util.EXIT_FAILURE_SETUP)
		}
	})

	// construction
	log.Timed("construction phase", "", func() {
		for _, module := range v.modules {
			ast.Construct(module, v.moduleLookup)
		}
	})
}
开发者ID:kiljacken,项目名称:ark,代码行数:86,代码来源:main.go


示例15: parseFiles


//.........这里部分代码省略.........
		for _, dep := range deps {
			depname := parser.NewModuleName(dep)
			modulesToRead = append(modulesToRead, depname)
			depGraph.AddDependency(modname, depname)
		}

		modules = append(modules, module)
	} else {
		if strings.ContainsAny(input, `\/. `) {
			setupErr("Invalid module name: %s", input)
		}

		modname := &parser.ModuleName{Parts: strings.Split(input, "::")}
		modulesToRead = append(modulesToRead, modname)
	}

	log.Timed("read/lex/parse phase", "", func() {
		for i := 0; i < len(modulesToRead); i++ {
			modname := modulesToRead[i]

			// Skip already loaded modules
			if _, err := moduleLookup.Get(modname); err == nil {
				continue
			}

			fi, dirpath := findModuleDir(*buildSearchpaths, modname.ToPath())
			if fi == nil {
				setupErr("Couldn't find module `%s`", modname)
			}

			if !fi.IsDir() {
				setupErr("Expected path `%s` to be directory, was file.", dirpath)
			}

			module := &parser.Module{
				Name:    modname,
				Dirpath: dirpath,
			}
			moduleLookup.Create(modname).Module = module

			// Check module children
			childFiles, err := ioutil.ReadDir(dirpath)
			if err != nil {
				setupErr("%s", err.Error())
			}

			for _, childFile := range childFiles {
				if strings.HasPrefix(childFile.Name(), ".") || !strings.HasSuffix(childFile.Name(), ".ark") {
					continue
				}

				actualFile := filepath.Join(dirpath, childFile.Name())

				// Read
				sourcefile, err := lexer.NewSourcefile(actualFile)
				if err != nil {
					setupErr("%s", err.Error())
				}

				// Lex
				sourcefile.Tokens = lexer.Lex(sourcefile)

				// Parse
				parsedFile, deps := parser.Parse(sourcefile)
				module.Trees = append(module.Trees, parsedFile)

				// Add dependencies to parse array
				for _, dep := range deps {
					depname := parser.NewModuleName(dep)
					modulesToRead = append(modulesToRead, depname)
					depGraph.AddDependency(modname, depname)
				}
			}

			modules = append(modules, module)
		}
	})

	// Check for cyclic dependencies (in modules)
	log.Timed("cyclic dependency check", "", func() {
		errs := depGraph.DetectCycles()
		if len(errs) > 0 {
			log.Errorln("main", "error: Encountered cyclic dependecies:")
			for _, cycle := range errs {
				log.Errorln("main", "%s", cycle)
			}
			os.Exit(util.EXIT_FAILURE_SETUP)
		}
	})

	// construction
	log.Timed("construction phase", "", func() {
		for _, module := range modules {
			parser.Construct(module, moduleLookup)

		}
	})

	return modules, moduleLookup
}
开发者ID:vnev,项目名称:ark,代码行数:101,代码来源:main.go


示例16: parseFiles

func parseFiles(inputs []string) ([]*parser.Module, *parser.ModuleLookup) {
	var modulesToRead []*parser.ModuleName
	for _, input := range inputs {
		if strings.ContainsAny(input, `\/. `) {
			setupErr("Invalid module name: %s", input)
		}

		modname := &parser.ModuleName{Parts: strings.Split(input, "::")}
		modulesToRead = append(modulesToRead, modname)
	}

	var parsedFiles []*parser.ParseTree
	moduleLookup := parser.NewModuleLookup("")
	depGraph := parser.NewDependencyGraph()

	log.Timed("read/lex/parse phase", "", func() {
		for i := 0; i < len(modulesToRead); i++ {
			modname := modulesToRead[i]
			actualFile := filepath.Join(*buildBasedir, modname.ToPath())

			fi, err := os.Stat(actualFile + ".ark")
			shouldBeDir := false
			if os.IsNotExist(err) {
				fi, err = os.Stat(actualFile)
				shouldBeDir = true
			}

			if err != nil {
				setupErr("%s", err.Error())
			}

			if !fi.IsDir() && shouldBeDir {
				setupErr("Expected file `%s` to be directory, was file.", actualFile)
			}

			// Check lookup
			ll := moduleLookup.Create(modname)
			if ll.Tree == nil {
				if shouldBeDir {
					// Setup dummy parse tree
					ll.Tree = &parser.ParseTree{}
					ll.Tree.Name = modname

					// Setup dummy module
					ll.Module = &parser.Module{}
					ll.Module.Path = actualFile
					ll.Module.Name = modname
					ll.Module.GlobalScope = parser.NewGlobalScope()

					// Check module children
					childFiles, err := ioutil.ReadDir(actualFile)
					if err != nil {
						setupErr("%s", err.Error())
					}

					for _, childFile := range childFiles {
						if strings.HasPrefix(childFile.Name(), ".") {
							continue
						}

						if childFile.IsDir() || strings.HasSuffix(childFile.Name(), ".ark") {
							childmodname := parser.JoinModuleName(modname, strings.TrimSuffix(childFile.Name(), ".ark"))
							modulesToRead = append(modulesToRead, childmodname)

							ll.Module.GlobalScope.UsedModules[childmodname.Last()] = moduleLookup.Create(childmodname)
						}
					}
				} else {
					// Read
					sourcefile, err := lexer.NewSourcefile(actualFile + ".ark")
					if err != nil {
						setupErr("%s", err.Error())
					}

					// Lex
					sourcefile.Tokens = lexer.Lex(sourcefile)

					// Parse
					parsedFile, deps := parser.Parse(sourcefile)
					parsedFile.Name = modname

					parsedFiles = append(parsedFiles, parsedFile)
					ll.Tree = parsedFile

					// Add dependencies to parse array
					for _, dep := range deps {
						depname := parser.NewModuleName(dep)
						modulesToRead = append(modulesToRead, depname)
						depGraph.AddDependency(modname, depname)
					}
				}
			}
		}
	})

	// Check for cyclic dependencies (in modules)
	log.Timed("cyclic dependency check", "", func() {
		errs := depGraph.DetectCycles()
		if len(errs) > 0 {
			log.Errorln("main", "error: Encountered cyclic dependecies:")
//.........这里部分代码省略.........
开发者ID:IanMurray,项目名称:ark,代码行数:101,代码来源:main.go


示例17: MapNames

func MapNames(nodes []ParseNode, tree *ParseTree, modules map[string]*ParseTree, parent *NameMap) *NameMap {
	nameMap := &NameMap{}
	nameMap.parent = parent
	nameMap.tree = tree
	nameMap.types = make(map[string]NodeType)
	nameMap.modules = make(map[string]*NameMap)
	previousLocation := make(map[string]lexer.Span)
	shouldExit := false

	var cModule *NameMap
	if parent == nil {
		for i := 0; i < len(_PrimitiveType_index); i++ {
			typ := PrimitiveType(i)
			name := typ.TypeName()
			nameMap.types[name] = NODE_PRIMITIVE
			previousLocation[name] = lexer.Span{Filename: "_builtin"}
		}
		cModule = &NameMap{
			types:   make(map[string]NodeType),
			modules: make(map[string]*NameMap),
		}
		cModule.types["uint"] = NODE_TYPE
		cModule.types["int"] = NODE_TYPE

		nameMap.types["C"] = NODE_MODULE
		nameMap.modules["C"] = cModule
	} else {
		cModule = parent.module(LocatedString{Value: "C"})
	}

	for _, node := range nodes {
		var name LocatedString
		var typ NodeType

		switch node.(type) {
		case *FunctionDeclNode:
			fdn := node.(*FunctionDeclNode)
			name, typ = fdn.Header.Name, NODE_FUNCTION

			if fdn.Header.IsMethod {
				continue // TODO is this right?
			}

			if fdn.Header.Attrs().Contains("c") || fdn.Attrs().Contains("c") {
				_, occupied := nameMap.modules["C"].types[name.Value]
				if occupied {
					startPos := name.Where.Start()
					log.Errorln("constructor", "[%s:%d:%d] Found duplicate definition of `%s`",
						tree.Source.Path, startPos.Line, startPos.Char, name.Value)
					log.Error("constructor", tree.Source.MarkSpan(name.Where))

					prevPos := previousLocation[name.Value]
					log.Errorln("constructor", "[%s:%d:%d] Previous declaration was here",
						tree.Source.Path, prevPos.StartLine, prevPos.StartChar)
					log.Error("constructor", tree.Source.MarkSpan(prevPos))
					shouldExit = true
				}
				cModule.types[name.Value] = typ
				previousLocation[name.Value] = name.Where
				continue
			}

		case *VarDeclNode:
			vd := node.(*VarDeclNode)
			name, typ = vd.Name, NODE_VARIABLE

		case *TypeDeclNode:
			vd := node.(*TypeDeclNode)
			name, typ = vd.Name, NODE_TYPE

			switch vd.Type.(type) {
			case *EnumTypeNode:
				typ = NODE_ENUM
			case *StructTypeNode:
				typ = NODE_STRUCT
			}

		case *UseDeclNode:
			udn := node.(*UseDeclNode)

			baseModuleName := udn.Module.Name
			if len(udn.Module.Modules) > 0 {
				baseModuleName = udn.Module.Modules[0]
			}

			mod, ok := modules[baseModuleName.Value]
			if !ok {
				startPos := baseModuleName.Where.Start()
				log.Errorln("constructor", "[%s:%d:%d] Unknown module `%s`",
					tree.Source.Path, startPos.Line, startPos.Char, baseModuleName.Value)
				log.Error("constructor", tree.Source.MarkSpan(baseModuleName.Where))
				shouldExit = true
			}
			nameMap.modules[baseModuleName.Value] = MapNames(mod.Nodes, mod, modules, nil)

			modNameMap := nameMap.modules[baseModuleName.Value]
			for _, mod := range udn.Module.Modules {
				nextMap, ok := modNameMap.modules[mod.Value]
				if !ok {
					startPos := mod.Where.Start()
//.........这里部分代码省略.........
开发者ID:dansawkins,项目名称:ark,代码行数:101,代码来源:name_pass.go



注:本文中的github.com/ark-lang/ark/src/util/log.Errorln函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang util.Blue函数代码示例发布时间:2022-05-24
下一篇:
Golang log.Error函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap