annotate sema/LiteralInterpreter.d @ 192:fda35d57847e

Fixed String parsing, so that they get created with the right type in AST. Also added so that you can parse options to the test program, that will mirror them to Dang. Eg. ./tests/run --semantic-only will pass --semantic-only to Dang on each run.
author Anders Johnsen <skabet@gmail.com>
date Fri, 25 Jul 2008 15:00:54 +0200
parents 6cb2f4201e2a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
106
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
1 module sema.LiteralInterpreter;
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
2
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
3 import sema.Visitor;
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
4
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
5 import basic.LiteralParsing,
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
6 basic.Message;
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
7
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
8 class LiteralInterpreter : Visitor!(void)
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
9 {
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
10 this(MessageHandler messages)
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
11 {
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
12 this.messages = messages;
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
13 }
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
14
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
15 void visit(Module[] modules)
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
16 {
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
17 super.visit(modules);
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
18 messages.checkErrors();
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
19 }
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
20
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
21 void visitStringExp(StringExp exp)
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
22 {
160
6cb2f4201e2a Improved static arrays
Anders Halager <halager@gmail.com>
parents: 119
diff changeset
23 auto str = parseString(exp.str, exp.loc, messages);
192
fda35d57847e Fixed String parsing, so that they get created with the right type in AST.
Anders Johnsen <skabet@gmail.com>
parents: 160
diff changeset
24 exp.data = str;
106
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
25 }
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
26
111
c658172ca8a0 Parsing basic integers and floats.
Anders Johnsen <skabet@gmail.com>
parents: 106
diff changeset
27 void visitIntegerLit(IntegerLit exp)
c658172ca8a0 Parsing basic integers and floats.
Anders Johnsen <skabet@gmail.com>
parents: 106
diff changeset
28 {
119
c0b531362ca6 Non compileing commit. Work on floating points and casts
Anders Johnsen <skabet@gmail.com>
parents: 111
diff changeset
29 exp.number = parseNumber(exp.name, exp.loc, messages);
111
c658172ca8a0 Parsing basic integers and floats.
Anders Johnsen <skabet@gmail.com>
parents: 106
diff changeset
30 }
c658172ca8a0 Parsing basic integers and floats.
Anders Johnsen <skabet@gmail.com>
parents: 106
diff changeset
31
106
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
32 MessageHandler messages;
89db676fbacb Now able of understanding strings.
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
33 }