Пример #1
0
func (i *SeqIterator) Inc() {
	if i.IsInRange() {
		i.int++
	} else {
		output.PrintString(deep, COL_RED_BB, "OUT OF RANGE Inc, .int: "+strconv.Itoa(i.int))
	}
}
Пример #2
0
func main() {
	output.InitWriter()
	fmt.Println("start")
	lexemeTypes, syntaxRules := utils.ParseXML(utils.Loadfile(utils.TermsFilePath, utils.TermsFileName)) // utils.ParseJSONLexemes("lexemes.json")
	sourceFile := "code1.txt"
	fileText := utils.LoadfileDefault(sourceFile)
	lexer.SetTokens(lexemeTypes)
	text := lexer.HandleSource(fileText)
	seq := lexer.ScanCycle(text)
	output.PrintString(0, []lexer.Lexeme(*seq))
	tree := controller.SyntaxCycle(seq, syntaxRules)
	output.CloseWriter()
	//fmt.Println(tree.ChildList[0].Type)
	htmlreport.MakeReport(tree)

	classStep := controller.ClassStep(controller.NewStep("SIGN"))
	step := controller.Step(&classStep)
	facade := controller.NewFacade(&step, nil, nil)
	fmt.Println("Test ", lexer.GetClassByName(facade.StepValue()))

	ruleStep := controller.RuleStep(controller.NewStep("program"))
	step = controller.Step(&ruleStep)
	facade = controller.NewFacade(&step, nil, nil)
	fmt.Println(facade.StepType(), facade.StepValue())
	b, ch := facade.HasChilds()
	fmt.Println("Test ", b, *ch)
}
Пример #3
0
//Init and control of parsing
func SyntaxCycle(sequence *lexer.LexemeSequence, syntaxRules []models.Rule) models.PTreeNode {
	seq = *sequence
	rules = syntaxRules
	startRule := "program"
	output.PrintString(0, *GetRule(startRule)) //TODO catch nil
	output.Par = *new(output.Paragraph)
	output.Par.Init()
	cursor := *NewIterator(0)
	Translate(&GetRule(startRule).TopWord, &cursor)
	if len(cursor.buffer.ChildList) == 0 {
		output.Par.Send(0, COL_RED_BB, "ZERO")
	}
	//output.Par.Write()
	deep = 0

	output.Par = *new(output.Paragraph)
	output.Par.Init()
	//PrintTree(*cursor.buffer)
	output.Par.Write()

	return cursor.buffer
}