Exemple #1
0
func getImports(symbols *symbols.Symbols) (imports []*importType) {
	imports = make([]*importType, 0, len(symbols.ImportIdList))
	for _, id := range symbols.ImportIdList {
		impType := &importType{
			Id:      id,
			ExtFunc: symbols.ExternalFunction(id),
			Type:    symbols.Type(id),
		}
		imports = append(imports, impType)
	}
	return
}
Exemple #2
0
func getAsciiTab(symbols *symbols.Symbols) map[rune]asciiType {
	asciiMap := make(map[rune]asciiType)
	for i, sym := range symbols.List() {
		if cl, exist := symbols.CharLitSymbols.GetSymbolId(sym); exist {
			if cl.Val < 0x100 {
				asciiMap[cl.Val] = asciiType{Type: i, Comment: sym}
			}
		}
	}
	return asciiMap
}
Exemple #3
0
/*
See Algorithm: set.Closure() in package doc
*/
func (this ItemList) Closure(lexPart *ast.LexPart, symbols *symbols.Symbols) ItemList {
	closure := this
	for i := 0; i < len(closure); i++ {
		expSym := closure[i].ExpectedSymbol()
		if regDefId, isRegDefId := expSym.(*ast.LexRegDefId); isRegDefId {
			if !this.ContainShift(expSym.String()) && !symbols.IsImport(regDefId.Id) {
				closure = closure.AddNoDuplicate(NewItem(regDefId.Id, lexPart, symbols).Emoves()...)
			}
		}
	}
	return closure
}
Exemple #4
0
func getCharRanges(symbols *symbols.Symbols) (ranges []CharRange) {
	ranges = make([]CharRange, symbols.CharRangeSymbols.Len())
	for i, rng := range symbols.CharRangeSymbols.List() {
		cr := CharRange{
			Min:     rng.From.Val,
			Max:     rng.To.Val,
			Type:    symbols.Type(rng.String()),
			Comment: rng.String(),
		}
		ranges[i] = cr
	}
	return
}