package main import "fmt" func Stmt() { fmt.Printf("%d",2) switch lookahead { case "expr": match("expr") match(";") case "if": match("if") match("(") match("expr") match(")") Stmt() case "for": match("for") match("(") optexpr() match(";") optexpr() match(";") optexpr() match(")") expr() case "other": match("other") default: report("syntax error") } } func optexpr(){ if lookahead == expr{ match(expr) } func (t terminal)match(){ if lookahead == t { lookahead=nextTerminal }else{ report("syntax error") } } func main() { }
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more