fixed f2
This commit is contained in:
parent
decc8f3324
commit
dadc137833
2 changed files with 16 additions and 21 deletions
|
|
@ -95,7 +95,6 @@ type format_F2_n struct {
|
|||
format int
|
||||
velikost int
|
||||
n string
|
||||
x bool // indeksno naslavljanje
|
||||
}
|
||||
|
||||
type format_F2_r struct {
|
||||
|
|
@ -113,7 +112,6 @@ type format_F2_rn struct {
|
|||
velikost int
|
||||
r1 string
|
||||
n string
|
||||
x bool
|
||||
}
|
||||
|
||||
type format_F2_rr struct {
|
||||
|
|
@ -125,13 +123,6 @@ type format_F2_rr struct {
|
|||
r2 string
|
||||
}
|
||||
|
||||
type format_F3 struct {
|
||||
oznaka string
|
||||
opcode int
|
||||
format int
|
||||
velikost int
|
||||
}
|
||||
|
||||
type format_F3_m struct {
|
||||
oznaka string
|
||||
opcode int
|
||||
|
|
@ -139,6 +130,11 @@ type format_F3_m struct {
|
|||
velikost int
|
||||
naslov string
|
||||
x bool
|
||||
b bool
|
||||
p bool
|
||||
e bool
|
||||
n bool
|
||||
i bool
|
||||
}
|
||||
|
||||
func remove_comments_and_empty_lines(el string) bool {
|
||||
|
|
@ -179,7 +175,7 @@ func check_F1(el string, AST *[]ukaz) bool {
|
|||
}
|
||||
|
||||
func check_F2_n(el string, AST *[]ukaz) bool {
|
||||
match_F2_n, err := regexp.MatchString(`(?m)^[A-Za-z_]*[\t ]+SVC ((#?|@?)[0-9]+)(, X)?[\t ]*(\..*)?$\n`, el)
|
||||
match_F2_n, err := regexp.MatchString(`(?m)^[A-Za-z_]*[\t ]+SVC ([0-9]+)[\t ]*(\..*)?$\n`, el)
|
||||
if err != nil {
|
||||
fmt.Println("Error while matching string.")
|
||||
}
|
||||
|
|
@ -194,13 +190,11 @@ func check_F2_n(el string, AST *[]ukaz) bool {
|
|||
} else {
|
||||
nov_ukaz.oznaka = ""
|
||||
}
|
||||
re_par := regexp.MustCompile(`[\t ]+(#?|@?)[0-9]+,?`)
|
||||
re_par := regexp.MustCompile(`[\t ]+[0-9]+,?`)
|
||||
temp := strings.Trim(re_par.FindString(el), "\t ")
|
||||
if temp[len(temp) - 1] == ',' {
|
||||
nov_ukaz.x = true
|
||||
nov_ukaz.n = strings.TrimRight(temp, ",")
|
||||
} else {
|
||||
nov_ukaz.x = false
|
||||
nov_ukaz.n = temp
|
||||
}
|
||||
//fmt.Println("F2_n ", el[:len(el) - 1], nov_ukaz)
|
||||
|
|
@ -237,7 +231,7 @@ func check_F2_r(el string, AST *[]ukaz) bool {
|
|||
}
|
||||
|
||||
func check_F2_rn(el string, AST *[]ukaz) bool {
|
||||
match_F2_rn, err := regexp.MatchString(`(?m)^[A-Za-z_]*[\t ]+[A-Za-z]+ (`+register+`), ((#?|@?)[0-9]+)(, X)?[\t ]*(\..*)?$\n`, el)
|
||||
match_F2_rn, err := regexp.MatchString(`(?m)^[A-Za-z_]*[\t ]+[A-Za-z]+ (`+register+`), ([0-9]+)[\t ]*(\..*)?$\n`, el)
|
||||
if err != nil {
|
||||
fmt.Println("Error while matching string.")
|
||||
}
|
||||
|
|
@ -255,13 +249,11 @@ func check_F2_rn(el string, AST *[]ukaz) bool {
|
|||
nov_ukaz.opcode = ukazna_tabela[strings.Trim(re_op.FindString(el), "\t ")]
|
||||
re_par1 := regexp.MustCompile(`[\t ]+[A-Za-z]+ (`+register+`)`)
|
||||
nov_ukaz.r1 = strings.Split(strings.Trim(re_par1.FindString(el), "\t \n"), " ")[1]
|
||||
re_par2 := regexp.MustCompile(`(`+register+`), ((#?|@?)[0-9]+),?`)
|
||||
re_par2 := regexp.MustCompile(`(`+register+`), ([0-9]+),?`)
|
||||
temp := strings.Split(re_par2.FindString(el), " ")[1]
|
||||
if temp[len(temp) - 1] == ',' {
|
||||
nov_ukaz.x = true
|
||||
nov_ukaz.n = strings.TrimRight(temp, ",")
|
||||
} else {
|
||||
nov_ukaz.x = false
|
||||
nov_ukaz.n = temp
|
||||
}
|
||||
//fmt.Println("F2_rn: ", el[:len(el) - 1], nov_ukaz)
|
||||
|
|
@ -299,6 +291,10 @@ func check_F2_rr(el string, AST *[]ukaz) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func check_F3_m(el string, AST *[]ukaz) bool {
|
||||
|
||||
}
|
||||
|
||||
// Pregledovalnik bere vhodne vrstice in jih razgradi na posamezne enote.
|
||||
// Razpoznane elemente okvalificira (oznaka / mnemonik / operand / komentar)
|
||||
// //<zbirniski stavek> ::== [<oznaka stavka>] <ločilo> <mnemonik> <ločilo> {<operand> <ločilo>} [<komentar>]
|
||||
|
|
@ -321,7 +317,6 @@ func main() {
|
|||
if check_F1(el, &AST) {
|
||||
continue
|
||||
}
|
||||
// TODO !!! odstrani # in @ in x naslalvljaje od F2 formata, saj nima bitov, da to podpre
|
||||
if check_F2_n(el, &AST) {
|
||||
continue
|
||||
}
|
||||
|
|
@ -334,6 +329,8 @@ func main() {
|
|||
if check_F2_rr(el, &AST) {
|
||||
continue
|
||||
}
|
||||
//match_F2, err := regexp.MatchString(`(?m)^[A-Za-z_]*[\t ]+[A-Za-z_]+[\t ](((`+register+`), (`+register+`))|((`+register+`), (#?|@?)[0-9]+)|(`+register+`))[\t ]*(\..*)?$\n`, el)
|
||||
if check_F3_m(el, &AST) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue