git @ Cat's Eye Technologies Velo / 50c2a85
Fix parser termination condition; add --ast flag. Now, methods... Cat's Eye Technologies 12 years ago
2 changed file(s) with 14 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
4747
4848 def expr
4949 debug "parsing Expr production"
50 if @scanner.type == 'EOF'
50 if (['EOL', 'EOF'].include? @scanner.type or [')', ','].include? @scanner.text)
5151 return nil
5252 end
5353 receiver = base # could be Expr, StringLit, Arg
54 if @scanner.type == 'EOF'
54 if (['EOL', 'EOF'].include? @scanner.type or [')', ','].include? @scanner.text)
5555 return receiver
5656 end
5757 while @scanner.consume '.'
6767 # lookup(a, b).set(c, foo)
6868 debug "unlookuping"
6969 ident = nil
70 if receiver.instance_of? Lookup
70 if receiver.is_a? Lookup
7171 ident = receiver.ident
7272 receiver = receiver.receiver
7373 else
66
77 ############ Main ############
88
9 ast = false
910 ARGV.each do |arg|
1011 if arg == '--debug'
1112 $debug = true
13 next
14 end
15 if arg == '--ast'
16 ast = true
1217 next
1318 end
1419 File.open(arg, 'r') do |f|
1823 end
1924 p = Parser.new(text)
2025 s = p.script
21 o = VeloObject.new 'main-script'
22 s.eval o, [] # XXX could pass command-line arguments here...
26 if ast
27 puts s
28 else
29 o = VeloObject.new 'main-script'
30 s.eval o, [] # XXX could pass command-line arguments here...
31 end
2332 end
2433 end