-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
49 lines (41 loc) · 873 Bytes
/
main.go
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"io"
// . "github.com/lexer-example/executor"
. "github.com/pascal-runtime-go/intermediate"
. "github.com/pascal-runtime-go/parser"
. "github.com/pascal-runtime-go/scanner"
. "github.com/pascal-runtime-go/source"
"strings"
)
type Pascal struct {
parser IParser
source *Source
iCode ICode
stack *SymTabStack
// executor Executor
}
func NewPascal(src io.Reader) *Pascal {
source := NewSource(src)
parser := NewPascalParser(NewPascalScanner(source))
parser.Parse()
return &Pascal{
parser: parser,
source: source,
iCode: parser.GetICode(),
stack: parser.GetSymTabStack(),
}
}
func main() {
NewPascal(strings.NewReader(
`PROGRAM HelloOnce;
VAR
i, j, k : integer;
x, y : real;
p, q : boolean;
ch : char;
index : 1..10;
BEGIN
writeln('Hello, world.')
END.`))
}