Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 22 lines (20 sloc) 0.721 kB
44f495f @charliesome js-to-js compiler to help verify that parsing works correctly
authored
1 $LOAD_PATH << File.expand_path("../lib", __FILE__)
2 require "twostroke"
4654d9a @fritzsche Fix: Termination on non unicode system + gitignore redcar tmp file
fritzsche authored
3 file = File.open(ARGV.first, "r:utf-8")
4 parser = Twostroke::Parser.new(Twostroke::Lexer.new(file.read))
44f495f @charliesome js-to-js compiler to help verify that parsing works correctly
authored
5 parser.parse
6
31f7816 @charliesome fix compile.rb
authored
7 compiler = Twostroke::Compiler::TSASM.new parser.statements
44f495f @charliesome js-to-js compiler to help verify that parsing works correctly
authored
8 compiler.compile
9
3ebd43e @charliesome compilation to speed up execution (parsing is slooooow), String.proto…
authored
10 if ARGV.include? "-S"
11 compiler.bytecode.each do |section,instructions|
12 puts "#{section}:"
13 instructions.each_with_index do |ins,offset|
14 puts "#{sprintf "%4d", offset} #{ins[0]}#{" " * (12 - ins[0].size)}#{ins.drop(1).map { |x| x.is_a?(String) ? x.inspect : x }.join ", "}"
15 end
31f7816 @charliesome fix compile.rb
authored
16 end
3ebd43e @charliesome compilation to speed up execution (parsing is slooooow), String.proto…
authored
17 else
18 File.open ARGV.first.gsub(/\.js$/, ".ts"), "w" do |f|
19 compiler.bytecode.default = nil
20 f.write Marshal.dump compiler.bytecode
21 end
22 end
Something went wrong with that request. Please try again.