aboutsummaryrefslogtreecommitdiff
path: root/main.go
blob: eeee6abff074f4e9fe966e02ef411ced01a3a0a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package main

//go:generate -command yacc goyacc
//go:generate yacc -o calc.go calc.y

import (
	"bufio"
	"fmt"
	"os"
)

const promt = "\t"

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	fmt.Print(promt)
	for scanner.Scan() {
		line := scanner.Text()
		result, ok := Parse(line)
		if ok {
			fmt.Printf("%v\n\n", result)
		}
		fmt.Print(promt)
	}
}