// lexAndParse conducts lexical analysis and parses the past file content, returns a parsed form and a potential error
func lexAndParse(fileContent []byte) (interfaces.Form, error) {
	lexer := lexer.NewLexer(fileContent)

	parser := parser.NewParser()
	log.Info("Initiating parsing of file")
	parseResult, parseErr := parser.Parse(lexer)

	if parseErr != nil {
		log.WithFields(log.Fields{"parseErr": parseErr}).Error("Could not parse")
	}

	log.WithFields(log.Fields{"Result": parseResult}).Info("Form parsed")

	parsedForm, parseResultIsForm := parseResult.(interfaces.Form)
	if parseErr == nil && !parseResultIsForm {
		log.Panic("Parse result could not be casted to Form")
	}

	return parsedForm, parseErr
}
func testStmtParse(t *testing.T, stmtAsString string, formFixture interfaces.Form) stmt.Form {
	lex := lexer.NewLexer([]byte(stmtAsString))
	parser := parser.NewParser()
	parseResult, err := parser.Parse(lex)

	if err != nil {
		t.Fatalf("Encountered fatal error during parse: %s", err)
	}

	if parsedForn, parseResultIsForm := parseResult.(stmt.Form); parseResultIsForm {
		if firstFormIdentifier, secondFormIdentifier := parsedForn.Identifier(), formFixture.Identifier(); firstFormIdentifier != secondFormIdentifier {
			t.Errorf("Form identifiers not equal: %s and %s", firstFormIdentifier, secondFormIdentifier)
		}

		if !util.AreStmtListsEqual(parsedForn.Content(), formFixture.Content()) {
			t.Errorf("Form content not equal: %v and %v", parsedForn, formFixture)
		}
	} else {
		t.Fatalf("Parse result is not form")
	}

	return parseResult.(stmt.Form)
}