Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Improve compiler a lot

  • Loading branch information...
commit 5e6d4f0aa8ee51180d9e9e769c6d31abdd9db134 1 parent 4fe68e2
@txus authored
View
28 Rakefile
@@ -2,6 +2,9 @@
require 'bundler'
Bundler::GemHelper.install_tasks
+require 'rake/clean'
+CLEAN.include "**/*.rbc", ".rbx"
+
desc "Regenerate Noscript's lexer and parser."
task :regenerate do
has_rex = `which rex`
@@ -20,6 +23,31 @@ task :regenerate do
end
end
+desc "regenerates lib/noscript/bootstrap/signature.rb"
+task :signature do
+ require 'digest/sha1'
+ digest = Digest::SHA1.new
+
+ files = Dir.glob('lib/noscript/{bootstrap,compiler}.rb')
+ files.each do |name|
+ File.open name, "r" do |file|
+ while chunk = file.read(1024)
+ digest << chunk
+ end
+ end
+ end
+
+ # Collapse the digest to a 64bit quantity
+ hd = digest.hexdigest
+ signature_hash = hd[0, 16].to_i(16) ^ hd[16,16].to_i(16) ^ hd[32,8].to_i(16)
+
+ File.open "lib/noscript/signature.rb", "wb" do |file|
+ file.puts "# This file is generated by `rake signature`. The signature"
+ file.puts "# is used to ensure that only current compiled files are loaded."
+ file.puts "Noscript::Signature = Rubinius::Signature ^ #{signature_hash}"
+ end
+end
+
require 'rake/testtask'
Rake::TestTask.new do |t|
t.libs << "test"
View
111 bin/noscript
@@ -1,64 +1,79 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env rbx
-begin
- require 'noscript'
-rescue LoadError
- require_relative '../lib/noscript'
+file = __FILE__
+file = File.readlink(file) while File.symlink? file
+$LOAD_PATH.unshift(File.expand_path('../../lib', file))
+
+Dir.chdir File.expand_path('..', file) do
+ system 'rake signature'
end
+require 'noscript'
require 'pp'
-parser = Noscript::Parser.new
+evals = []
+settings = Hash.new { |h,k| h[k] = false }
+options = Rubinius::Options.new "Usage: #$0 [options] [script]", 20
+
+options.on( "-A", "Print the AST" ) { settings[:ast] = true }
+options.on( "-B", "Print the bytecode" ) { settings[:bc] = true }
-filename = ARGV.shift
-if filename && code = File.read(filename)
- code.strip!
-else
- puts "No input file provided. Bye!"
- exit(1)
+options.on "-e", "CODE", "Execute CODE" do |e|
+ evals << ['(eval)', e]
end
-args = ARGV
-
-begin
- if compile = args.detect{|a| a =~ /-c/}
- case compile
- when "-cjs"
- str = File.read(filename)
- compiler = Noscript::Compiler.new(Noscript::JavascriptGenerator)
- parser = compiler.parser
- compiled = compiler.compile(str)
- STDOUT.print compiled
- end
- return
- else
- ast = parser.scan_file(filename)
- end
-rescue
- $stderr.printf "Syntax error\n\t%s:%d:%s\n", parser.filename, parser.lineno, $!.message
+options.on "-v", "--version", "Show version" do
+ puts "Noscript #{Noscript::VERSION}"
+ exit 0
end
-if args.any?{|a| a =~ /--tokens/}
- puts "-----TOKENS-----"
- lexer = Noscript::Parser.new
- lexer.load_file filename
- while token = lexer.next_token
- p token
- end
- puts
+options.on "-h", "--help", "Display this help" do
+ puts options
+ exit 0
+end
+
+info = proc do |cond, name, &block|
+ next unless settings[cond]
+ puts '', " #{name} ".center(80, "=")
+ block[]
+ puts "-" * 80, ''
end
-if ast
- if args.any?{|a| a =~ /--ast/}
- puts "-----AST-----"
- pp ast
- puts
+display = proc do |file, code, ev=true|
+ begin
+ if settings[:ast]
+ ast = Noscript::Parser.new.parse_string(code)
+ info.call(:ast, 'AST') { Rubinius::AST::AsciiGrapher.new(ast).print }
+ end
+
+ info.call(:bc, "Bytecode") { puts Noscript::Compiler.compile_string(code, file).decode }
+ if ev
+ puts "=> %p" % Noscript.eval_noscript(code, file)
+ else
+ Noscript.eval_noscript(code, file)
+ end
+
+ rescue Exception => e
+ e.render
end
-#
-# result = ast.compile(Noscript.bootstrap)
+end
+
+options.parse(ARGV).each do |file|
+ evals << [file, File.read(file), false]
+end
- if args.any?{|a| a =~ /--return/}
- puts "-----RETURN VALUE-----"
- # pp result
+if evals.empty?
+ if $stdin.tty?
+ require 'readline'
+ loop do
+ code = Readline.readline "ns> "
+ exit 0 unless code and code != "exit"
+ display['(repl)', code]
+ end
+ else
+ evals << ['(stdin)', STDIN.read]
end
end
+
+evals.each(&display)
+
View
29 examples/hello_world.ns
@@ -3,27 +3,27 @@ johnny = 4000
oh my god = 'lord'
-foo = -> johnny=3
+foo = -> johnny
34 + johnny * 3
end
-bar = -> johnny=3
+bar = -> johnny
(34 + johnny) * 3
end
-puts('Negative johnny is', -johnny)
+Object.puts('Negative johnny is', -johnny)
-puts(foo())
-puts(foo(242))
+Object.puts(foo(3))
+Object.puts(foo(242))
-if bar() == 111
- puts(bar())
+if bar(3) == 111
+ Object.puts(bar(3))
end
if bar(242) == 728
- puts('wrong!')
+ Object.puts('wrong!')
else
- puts('cool!')
+ Object.puts('cool!')
end
foo = 30
@@ -38,16 +38,15 @@ end
cool object = Object.clone()
cool object.foo = 'bar'
cool object.bar = -> a
- { foo: a, bar: 'baz' }
'baz'
end
-puts(cool object.foo)
-puts(cool object.bar(3))
+Object.puts(cool object.foo)
+Object.puts(cool object.bar(3))
-puts('Johnny is still', johnny)
+Object.puts('Johnny is still', johnny)
-puts(oh my god)
+Object.puts(oh my god)
-puts(myvar)
+Object.puts(myvar)
View
46 lib/noscript.rb
@@ -1,10 +1,40 @@
-require_relative 'noscript/ast'
-require_relative 'noscript/parser'
-require_relative 'noscript/compiler'
-require_relative 'noscript/generator'
-require_relative 'noscript/scope'
-require_relative 'noscript/code'
-require_relative 'noscript/bootstrap'
-
module Noscript
+ require_relative 'noscript/version'
+ require_relative 'noscript/ast'
+ require_relative 'noscript/parser'
+ require_relative 'noscript/compiler'
+ require_relative 'noscript/generator'
+ require_relative 'noscript/scope'
+ require_relative 'noscript/code'
+ require_relative 'noscript/runtime'
+ require_relative 'noscript/code_loader'
+
+ CodeLoader.load_paths << File.expand_path('../noscript', __FILE__)
+ # CodeLoader.run('kernel/Alpha')
+
+ def self.eval_noscript(code, *args)
+ file, line, binding = '(eval)', 1, Runtime.send(:binding)
+ args.each do |arg|
+ case arg
+ when String then file = arg
+ when Integer then line = arg
+ when Binding then binding = arg
+ else raise ArgumentError
+ end
+ end
+
+ cm = Noscript::Compiler.compile_eval(code, binding.variables, file, line)
+ cm.scope = Rubinius::StaticScope.new(Runtime)
+ cm.name = :__noscript__
+ script = Rubinius::CompiledMethod::Script.new(cm, file, true)
+ be = Rubinius::BlockEnvironment.new
+
+ script.eval_binding = binding
+ script.eval_source = code
+ cm.scope.script = script
+
+ be.under_context(binding.variables, cm)
+ be.from_eval!
+ be.call
+ end
end
View
3  lib/noscript/ast.rb
@@ -2,7 +2,7 @@ module Noscript
module AST
RubiniusNodes = [
:Node, :StringLiteral, :FixnumLiteral, :ArrayLiteral, :HashLiteral,
- :TrueLiteral, :FalseLiteral, :NilLiteral,
+ :TrueLiteral, :FalseLiteral, :NilLiteral, :EvalExpression,
:ClosedScope,
]
RubiniusNodes.each { |n| const_set(n, Rubinius::AST.const_get(n)) }
@@ -21,6 +21,7 @@ module Noscript
module AST
class Script < Node
attr_reader :body, :filename
+ attr_accessor :variable_scope
def initialize(line, filename, body)
super(line)
View
92 lib/noscript/code_loader.rb
@@ -0,0 +1,92 @@
+module Noscript
+ class CodeLoader
+ @load_paths = []
+ @loaded_files
+
+ class << self
+ attr_reader :load_paths, :loaded_files
+
+ def check_version?
+ Rubinius::CodeLoader.check_version
+ end
+
+ def compiled_hook
+ Rubinius::CodeLoader.compiled_hook
+ end
+
+ def loaded_hook
+ Rubinius::CodeLoader.loaded_hook
+ end
+
+ def save_compiled?
+ Rubinius::CodeLoader.save_compiled?
+ end
+
+ def run(file, wrap = false)
+ new(file).run(wrap)
+ end
+
+ def new(path)
+ path += '.ns' unless path =~/\.ns$/
+ load_paths.detect do |dir|
+ joined = File.expand_path(path, dir)
+ path = joined if File.exist? joined
+ end
+ super path
+ end
+ end
+
+ attr_reader :path, :cm
+
+ def initialize(path)
+ @path = path
+ @stat = File.stat(path)
+ end
+
+ def run(wrap = false)
+ load_file(wrap)
+ Rubinius.run_script(@cm)
+ Rubinius::CodeLoader.loaded_hook.trigger! @path
+ true
+ end
+
+ def load_file(wrap = false)
+ signature = check_version? ? Noscript::Signature : 0
+ version = Rubinius::RUBY_LIB_VERSION
+ compiled = Noscript::Compiler.compiled_name path
+
+ if compiled and File.exist? compiled and @stat.mtime < File.mtime(compiled)
+ begin
+ cm = load_compiled_file(compiled, signature, version)
+ rescue TypeError, Rubinius::InvalidRBC
+ end
+ end
+
+ cm ||= compile_file(@path, compiled)
+ script = cm.create_script(wrap)
+ script.file_path = @path
+ script.data_path = @path
+
+ @cm = cm
+ self.class.compiled_hook.trigger! script
+ script
+ end
+
+ def compile_file(file, compiled)
+ if self.class.save_compiled?
+ Noscript::Compiler.compile(file, compiled)
+ else
+ Noscript::Compiler.compile_file(file)
+ end
+ end
+
+ def load_compiled_file(path, signature, version)
+ Rubinius.primitive :compiledfile_load
+ raise Rubinius::InvalidRBC, path
+ end
+
+ def check_version?
+ self.class.check_version?
+ end
+ end
+end
View
221 lib/noscript/compiler.rb
@@ -1,7 +1,169 @@
require 'rexpl'
module Noscript
- class Compiler
+ class Compiler < Rubinius::Compiler
+ # module Noscriptify
+ # Rubinius::Compiler::Stage.extend self
+
+ # def new(compiler, *args, &block)
+ # if compiler.is_a? Noscript::Compiler and name =~ /^Rubinius::Compiler::([^:]+)$/
+ # const = Noscript::Compiler.const_get($1)
+ # return const.new(compiler, *args, &block) if const != self
+ # end
+ # super
+ # end
+ # end
+
+ # def self.noscript_compiled_name(file)
+ # if file.suffix? ".ns"
+ # file + "c"
+ # else
+ # file + ".compiled.nsc"
+ # end
+ # end
+
+ # def self.compile_fancy_file(file, output = nil, line = 1, print = false)
+ # compiler = new :fancy_file, :compiled_file
+
+ # parser = compiler.parser
+ # parser.root Noscript::AST::Script
+
+ # parser.input file, line
+
+ # if print
+ # parser.print
+ # printer = compiler.packager.print
+ # printer.bytecode = true
+ # end
+
+ # writer = compiler.writer
+ # writer.name = output ? output : noscript_compiled_name(file)
+
+ # begin
+ # compiler.run
+ # rescue Exception => e
+ # compiler_error "Error trying to compile noscript: #{file}", e
+ # end
+ # end
+
+ def self.compile_eval(string, variable_scope, file="(eval)", line=1)
+ if ec = @eval_cache
+ layout = variable_scope.local_layout
+ if cm = ec.retrieve([string, layout, line])
+ return cm
+ end
+ end
+
+ compiler = new :noscript_eval, :compiled_method
+
+ parser = compiler.parser
+ parser.root Rubinius::AST::EvalExpression
+ parser.input string, file, line
+
+ compiler.generator.variable_scope = variable_scope
+
+ cm = compiler.run
+
+ cm.add_metadata :for_eval, true
+
+ if ec and parser.should_cache?
+ ec.set([string.dup, layout, line], cm)
+ end
+
+ return cm
+ end
+
+ # AST -> symbolic bytecode
+ class Generator < Stage
+ stage :bytecode
+ next_stage Rubinius::Compiler::Encoder
+
+ attr_accessor :variable_scope
+
+ def initialize(compiler, last)
+ super
+ @variable_scope = nil
+ compiler.generator = self
+ @compiler = Noscript::BytecodeCompiler
+ end
+
+ def run
+ compiler = @compiler.new
+ @output = compiler.compile(@input)
+ run_next
+ end
+ end
+
+ class Parser < Rubinius::Compiler::Parser
+ def initialize(compiler, last)
+ super
+
+ @compiler = compiler
+ @processor = Noscript::Parser
+ end
+
+ def create
+ # TODO: we totally ignore @transforms
+ @parser = @processor.new
+ @parser
+ end
+
+ # def run
+ # @output = @root.new parse
+ # @output.file = @file
+ # run_next
+ # end
+ end
+
+ class FileParser < Parser
+ stage :noscript_file
+ next_stage Noscript::Compiler::Generator
+
+ def input(file, line = 1)
+ @file = file
+ @line = line
+ end
+
+ def parse
+ create.parse_file
+ end
+ end
+
+ class StringParser < Parser
+ stage :noscript_string
+ next_stage Noscript::Compiler::Generator
+
+ def input(string, name = "(eval)", line = 1)
+ @input = string
+ @file = name
+ @line = line
+ end
+
+ def parse
+ create.parse_string(@input)
+ end
+ end
+
+ class EvalParser < StringParser
+ stage :noscript_eval
+ next_stage Noscript::Compiler::Generator
+
+ def should_cache?
+ @output.should_cache?
+ end
+ end
+
+ class Writer < Rubinius::Compiler::Writer
+ def initialize(compiler, last)
+ super
+ @signature = Noscript::Signature
+ end
+ end
+ end
+end
+
+module Noscript
+ class BytecodeCompiler
attr_reader :generator, :scope
alias g generator
alias s scope
@@ -10,16 +172,15 @@ def initialize(parent=nil)
@generator = Generator.new
parent_scope = parent ? parent.scope : nil
@scope = Scope.new(@generator, parent_scope)
- @generator.push_state(@scope)
end
def compile(ast, debugging=false)
- ast = Noscript::Parser.new.parse(ast) unless ast.kind_of?(AST::Node)
-
- # require 'pp'
- # pp ast
+ if debugging
+ require 'pp'
+ pp ast
+ end
- g.name = :call
+ ast = ast.body if ast.kind_of?(Rubinius::AST::EvalExpression)
if ast.respond_to?(:filename) && ast.filename
g.file = ast.filename
@@ -27,29 +188,14 @@ def compile(ast, debugging=false)
g.file = :"(noscript)"
end
- g.set_line 1
-
- g.required_args = 0
- g.total_args = 0
- g.splat_index = nil
+ g.set_line ast.line || 1
ast.accept(self)
debug if debugging
-
g.ret
finalize
-
- g.encode
- cm = g.package Rubinius::CompiledMethod
- puts cm.decode if $DEBUG
-
- code = Code.new
- ss = Rubinius::StaticScope.new Runtime
- Rubinius.attach_method g.name, cm, ss, code
-
- code
end
def visit_Script(o)
@@ -67,7 +213,7 @@ def visit_Nodes(o)
def visit_FunctionLiteral(o)
set_line(o)
# Get a new compiler
- block = Compiler.new(self)
+ block = BytecodeCompiler.new(self)
# Configures the new generator
# TODO Move this to a method on the compiler
@@ -101,23 +247,23 @@ def visit_arguments(args)
end
def visit_CallNode(o)
- meth = nil
+ meth = o.method.respond_to?(:name) ? o.method.name.to_sym : o.method.to_sym
+
if o.receiver
- meth = o.method.is_a?(String) ? o.method : o.method.name
o.receiver.accept(self)
else
meth = :call
- visit_Identifier(o.method)
+
+ visit_Identifier(o.method, true)
end
o.arguments.each do |argument|
argument.accept(self)
end
-
g.noscript_send meth, o.arguments.length
end
- def visit_Identifier(o)
+ def visit_Identifier(o, for_method=false)
set_line(o)
if o.constant?
@@ -128,7 +274,7 @@ def visit_Identifier(o)
if s.slot_for(o.name)
visit_LocalVariableAccess(o)
else
- g.push_nil
+ raise "Undefined identifier #{o.name}"
end
end
@@ -225,3 +371,18 @@ def debug(gen = self.g)
end
end
end
+
+class Noscript::Compiler::Generator
+ def initialize(compiler, last)
+ super
+ @variable_scope = nil
+ compiler.generator = self
+ @compiler = Noscript::BytecodeCompiler
+ end
+
+ def run
+ compiler = @compiler.new
+ @output = compiler.compile(@input)
+ run_next
+ end
+end
View
17 lib/noscript/parser.rb
@@ -1 +1,18 @@
require_relative 'parser/parser'
+
+module Noscript
+ class Parser
+ def initialize(*)
+ super
+ @line = 1
+ end
+
+ def parse_file(filename, log = false)
+ parse_string(File.read(filename), filename, log)
+ end
+
+ def parse_string(input, file = '(eval)', log = false)
+ scan_str(input.strip)
+ end
+ end
+end
View
5 lib/noscript/parser/noscript.y
@@ -198,7 +198,8 @@ rule
| Expression '*' Expression { result = CallNode.new(lineno, val[0], val[1], [val[2]]) }
| Expression '/' Expression { result = CallNode.new(lineno, val[0], val[1], [val[2]]) }
# Unary operators
- | '!' Expression { result = CallNode.new(lineno, val[1], val[0], []) }
+ | '!' Expression { result = CallNode.new(lineno, val[1], '@!', []) }
+ | '-' Expression { result = CallNode.new(lineno, val[1], '@-', []) }
;
ParamList:
@@ -235,7 +236,7 @@ require_relative 'lexer'
include AST
def parse(code)
- scan_str(code.strip)
+ parse_string(code, filename)
end
---- footer ----
View
570 lib/noscript/parser/parser.rb
@@ -14,274 +14,340 @@
module Noscript
class Parser < Racc::Parser
-module_eval(<<'...end noscript.y/module_eval...', 'noscript.y', 234)
+module_eval(<<'...end noscript.y/module_eval...', 'noscript.y', 235)
include AST
def parse(code)
- scan_str(code.strip)
+ parse_string(code, filename)
end
...end noscript.y/module_eval...
##### State transition tables begin ###
racc_action_table = [
- -1, 36, 32, 100, 33, 5, 17, 18, 22, 23,
- 24, 30, 30, 5, -5, 31, 32, -5, 33, -5,
- 17, 18, 22, 23, 24, 30, -5, 98, 5, 31,
- 6, 16, 101, 25, 27, 126, 99, 29, 6, 108,
- 105, 111, 107, 51, -5, 16, 93, 25, 27, 5,
- 32, 29, 33, 6, 17, 18, 22, 23, 24, 30,
- 32, 36, 33, 31, 17, 18, 22, 23, 24, 30,
- 94, 64, 49, 31, 6, 51, 92, 30, 122, 16,
- 5, 25, 27, 30, 30, 29, 34, 121, 65, 16,
- 5, 25, 27, 59, 32, 29, 33, 120, 17, 18,
- 22, 23, 24, 30, 32, 6, 33, 31, 17, 18,
- 22, 23, 24, 30, 64, 6, 36, 31, 47, 48,
- 30, 30, 114, 16, 5, 25, 27, 36, 69, 29,
- nil, 123, nil, 16, 5, 25, 27, nil, 32, 29,
- 33, nil, 17, 18, 22, 23, 24, 30, 32, 6,
- 33, 31, 17, 18, 22, 23, 24, 30, 90, 6,
- 36, 31, 47, 48, 45, 46, nil, 16, nil, 25,
- 27, nil, 36, 29, 47, 48, nil, 16, nil, 25,
- 27, nil, 32, 29, 33, nil, 17, 18, 22, 23,
- 24, 30, 32, nil, 33, 31, 17, 18, 22, 23,
- 24, 30, nil, nil, 36, 31, 47, 48, 45, 46,
- nil, 16, 86, 25, 27, nil, nil, 29, nil, nil,
- nil, 16, nil, 25, 27, nil, 32, 29, 33, nil,
- 17, 18, 22, 23, 24, 30, 32, nil, 33, 31,
- 17, 18, 22, 23, 24, 30, nil, nil, 36, 31,
- 47, 48, 45, 46, nil, 16, nil, 25, 27, nil,
- nil, 29, nil, nil, nil, 16, nil, 25, 27, nil,
- 32, 29, 33, nil, 17, 18, 22, 23, 24, 30,
- 32, nil, 33, 31, 17, 18, 22, 23, 24, 30,
- nil, nil, 36, 31, 47, 48, 45, 46, nil, 16,
- nil, 25, 27, nil, nil, 29, nil, nil, nil, 16,
- nil, 25, 27, nil, 32, 29, 33, nil, 17, 18,
- 22, 23, 24, 30, 32, nil, 33, 31, 17, 18,
+ -1, 37, 33, 5, 34, 5, 17, 18, 22, 23,
+ 24, 30, 65, 110, 65, 31, 109, 30, 30, 32,
+ 30, 37, 30, 48, 49, 102, 95, 5, 6, 5,
+ 6, 16, 107, 25, 27, 52, -5, 29, 33, -5,
+ 34, -5, 17, 18, 22, 23, 24, 30, -5, 100,
+ 96, 31, 6, 92, 6, 32, 94, 5, 101, 124,
+ 37, 5, 48, 49, 125, 113, -5, 16, 123, 25,
+ 27, 37, 33, 29, 34, 60, 17, 18, 22, 23,
+ 24, 30, 6, 71, 5, 31, 6, 50, 30, 32,
+ 52, 122, 5, 37, 30, 48, 49, 46, 47, 128,
+ 103, 16, 66, 25, 27, 116, 33, 29, 34, 6,
+ 17, 18, 22, 23, 24, 30, 37, 6, 37, 31,
+ 48, 49, 37, 32, 48, 49, 46, 47, 42, 43,
+ 44, 45, 40, 41, 39, 16, 35, 25, 27, nil,
+ 33, 29, 34, nil, 17, 18, 22, 23, 24, 30,
+ nil, nil, nil, 31, nil, nil, 37, 32, 48, 49,
+ 46, 47, 42, 43, 44, 45, 40, 41, nil, 16,
+ nil, 25, 27, nil, 33, 29, 34, nil, 17, 18,
22, 23, 24, 30, nil, nil, nil, 31, nil, nil,
- nil, nil, nil, 16, nil, 25, 27, nil, nil, 29,
- nil, nil, nil, 16, nil, 25, 27, nil, 32, 29,
- 33, nil, 17, 18, 22, 23, 24, 30, nil, nil,
- 32, 31, 33, 5, 17, 18, 22, 23, 24, 30,
- nil, nil, nil, 31, nil, nil, nil, 16, nil, 25,
- 27, nil, nil, 29, nil, nil, nil, nil, 6, 16,
- nil, 25, 27, nil, 32, 29, 33, 58, 17, 18,
- 22, 23, 24, 30, nil, nil, 32, 31, 33, 5,
+ 37, 32, 48, 49, 46, 47, 42, 43, 44, 45,
+ nil, nil, nil, 16, nil, 25, 27, nil, 33, 29,
+ 34, nil, 17, 18, 22, 23, 24, 30, nil, nil,
+ nil, 31, nil, nil, 37, 32, 48, 49, 46, 47,
+ 42, 43, 44, 45, nil, nil, nil, 16, nil, 25,
+ 27, nil, 33, 29, 34, nil, 17, 18, 22, 23,
+ 24, 30, nil, nil, nil, 31, nil, nil, 37, 32,
+ 48, 49, 46, 47, 37, nil, 48, 49, 46, 47,
+ nil, 16, nil, 25, 27, nil, 33, 29, 34, nil,
17, 18, 22, 23, 24, 30, nil, nil, nil, 31,
- nil, -33, nil, 16, nil, 25, 27, -33, nil, 29,
+ nil, nil, 37, 32, 48, 49, 46, 47, nil, nil,
+ nil, nil, nil, nil, nil, 16, nil, 25, 27, nil,
+ 33, 29, 34, nil, 17, 18, 22, 23, 24, 30,
+ nil, nil, nil, 31, nil, nil, nil, 32, nil, nil,
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, 16,
+ nil, 25, 27, nil, 33, 29, 34, nil, 17, 18,
+ 22, 23, 24, 30, nil, nil, nil, 31, nil, nil,
+ nil, 32, nil, nil, nil, nil, nil, nil, nil, nil,
+ nil, nil, nil, 16, nil, 25, 27, nil, 33, 29,
+ 34, nil, 17, 18, 22, 23, 24, 30, nil, nil,
+ nil, 31, nil, nil, nil, 32, nil, nil, nil, nil,
+ nil, nil, nil, nil, nil, nil, nil, 16, nil, 25,
+ 27, nil, 33, 29, 34, nil, 17, 18, 22, 23,
+ 24, 30, nil, nil, nil, 31, nil, nil, nil, 32,
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
+ nil, 16, 88, 25, 27, nil, 33, 29, 34, nil,
+ 17, 18, 22, 23, 24, 30, nil, nil, nil, 31,
+ nil, nil, nil, 32, nil, nil, nil, nil, nil, nil,
+ nil, nil, nil, nil, nil, 16, nil, 25, 27, nil,
+ 33, 29, 34, nil, 17, 18, 22, 23, 24, 30,
+ nil, nil, nil, 31, nil, nil, nil, 32, nil, nil,
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, 16,
+ nil, 25, 27, nil, 33, 29, 34, nil, 17, 18,
+ 22, 23, 24, 30, nil, nil, nil, 31, nil, nil,
+ nil, 32, nil, nil, nil, nil, nil, nil, nil, nil,
+ nil, nil, nil, 16, nil, 25, 27, nil, 33, 29,
+ 34, 5, 17, 18, 22, 23, 24, 30, nil, nil,
+ nil, 31, nil, nil, nil, 32, nil, nil, nil, nil,
+ nil, nil, nil, nil, nil, nil, 6, 16, nil, 25,
+ 27, nil, 33, 29, 34, nil, 17, 18, 22, 23,
+ 24, 30, nil, nil, nil, 31, nil, nil, nil, 32,
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
+ nil, 16, nil, 25, 27, nil, 33, 29, 34, 5,
+ 17, 18, 22, 23, 24, 30, nil, nil, nil, 31,
+ nil, nil, nil, 32, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, 6, 16, nil, 25, 27, nil,
- 32, 29, 33, nil, 17, 18, 22, 23, 24, 30,
- nil, nil, 32, 31, 33, 58, 17, 18, 22, 23,
- 24, 30, nil, nil, nil, 31, nil, nil, nil, 16,
- nil, 25, 27, nil, nil, 29, nil, nil, nil, nil,
- nil, 16, nil, 25, 27, nil, 32, 29, 33, nil,
- 17, 18, 22, 23, 24, 30, 32, nil, 33, 31,
+ 33, 29, 34, nil, 17, 18, 22, 23, 24, 30,
+ nil, nil, nil, 31, nil, nil, nil, 32, nil, nil,
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, 16,
+ nil, 25, 27, nil, 33, 29, 34, 59, 17, 18,
+ 22, 23, 24, 30, nil, nil, nil, 31, nil, nil,
+ nil, 32, nil, nil, nil, nil, nil, nil, nil, nil,
+ nil, nil, nil, 16, nil, 25, 27, nil, 33, 29,
+ 34, nil, 17, 18, 22, 23, 24, 30, nil, nil,
+ nil, 31, nil, nil, nil, 32, nil, nil, nil, nil,
+ nil, nil, nil, nil, nil, nil, nil, 16, nil, 25,
+ 27, nil, 33, 29, 34, nil, 17, 18, 22, 23,
+ 24, 30, nil, nil, nil, 31, nil, nil, nil, 32,
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
+ nil, 16, nil, 25, 27, nil, 33, 29, 34, nil,
17, 18, 22, 23, 24, 30, nil, nil, nil, 31,
+ nil, nil, nil, 32, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, 16, nil, 25, 27, nil,
- nil, 29, nil, nil, nil, 16, nil, 25, 27, nil,
- 32, 29, 33, nil, 17, 18, 22, 23, 24, 30,
- nil, nil, 32, 31, 33, 5, 17, 18, 22, 23,
- 24, 30, nil, nil, nil, 31, nil, nil, nil, 16,
- nil, 25, 27, nil, nil, 29, nil, nil, nil, nil,
- 6, 16, nil, 25, 27, nil, 32, 29, 33, nil,
- 17, 18, 22, 23, 24, 30, nil, nil, 32, 31,
- 33, 5, 17, 18, 22, 23, 24, 30, nil, nil,
- nil, 31, nil, nil, nil, 16, nil, 25, 27, nil,
- nil, 29, nil, nil, nil, nil, 6, 16, nil, 25,
- 27, nil, 32, 29, 33, nil, 17, 18, 22, 23,
- 24, 30, 32, nil, 33, 31, 17, 18, 22, 23,
- 24, 30, nil, nil, nil, 31, nil, nil, nil, nil,
- nil, 16, nil, 25, 27, nil, nil, 29, nil, 5,
- nil, 16, nil, 25, 27, nil, nil, 29, 36, nil,
- 47, 48, 45, 46, 41, 42, 43, 44, 39, 40,
- 38, 37, 5, nil, 6, nil, nil, nil, nil, nil,
- nil, 36, nil, 47, 48, 45, 46, 41, 42, 43,
- 44, 39, 40, 38, 37, 95, nil, 6, nil, nil,
- nil, nil, nil, nil, 36, nil, 47, 48, 45, 46,
- 41, 42, 43, 44, 39, 40, 38, 37, 36, nil,
- 47, 48, 45, 46, 41, 42, 43, 44, 39, 40,
- 38, 37, nil, nil, nil, 36, 88, 47, 48, 45,
- 46, 41, 42, 43, 44, 39, 40, 38, 37, 36,
- nil, 47, 48, 45, 46, 41, 42, 43, 44, 39,
- 40, 38, 37, 36, nil, 47, 48, 45, 46, 41,
- 42, 43, 44, 39, 40, 38, 37, 36, nil, 47,
- 48, 45, 46, 41, 42, 43, 44, 39, 40, 38,
- 37, 36, nil, 47, 48, 45, 46, 41, 42, 43,
- 44, 39, 40, 38, 37, 36, nil, 47, 48, 45,
- 46, 41, 42, 43, 44, 39, 40, 38, 37, 36,
- nil, 47, 48, 45, 46, 41, 42, 43, 44, 39,
- 40, 38, 37, 36, nil, 47, 48, 45, 46, 41,
- 42, 43, 44, 39, 40, 38, 37, 36, nil, 47,
- 48, 45, 46, 41, 42, 43, 44, 39, 40, 38,
- 36, nil, 47, 48, 45, 46, 41, 42, 43, 44,
- 39, 40, 36, nil, 47, 48, 45, 46, 41, 42,
- 43, 44, 36, nil, 47, 48, 45, 46, 41, 42,
- 43, 44 ]
+ 33, 29, 34, 5, 17, 18, 22, 23, 24, 30,
+ nil, nil, nil, 31, nil, nil, nil, 32, nil, nil,
+ nil, nil, nil, nil, nil, nil, nil, nil, 6, 16,
+ nil, 25, 27, nil, 33, 29, 34, 59, 17, 18,
+ 22, 23, 24, 30, nil, nil, nil, 31, nil, nil,
+ nil, 32, nil, nil, nil, nil, nil, nil, nil, nil,
+ nil, -33, nil, 16, nil, 25, 27, -33, 33, 29,
+ 34, 5, 17, 18, 22, 23, 24, 30, nil, nil,
+ nil, 31, nil, nil, nil, 32, nil, nil, nil, nil,
+ nil, nil, nil, nil, nil, nil, 6, 16, nil, 25,
+ 27, nil, 33, 29, 34, nil, 17, 18, 22, 23,
+ 24, 30, nil, nil, nil, 31, nil, nil, nil, 32,
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
+ nil, 16, nil, 25, 27, nil, 33, 29, 34, nil,
+ 17, 18, 22, 23, 24, 30, nil, nil, nil, 31,
+ nil, nil, nil, 32, nil, nil, nil, nil, nil, nil,
+ nil, nil, nil, nil, nil, 16, nil, 25, 27, nil,
+ 33, 29, 34, nil, 17, 18, 22, 23, 24, 30,
+ nil, nil, nil, 31, nil, nil, nil, 32, nil, nil,
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, 16,
+ nil, 25, 27, nil, 33, 29, 34, nil, 17, 18,
+ 22, 23, 24, 30, nil, nil, nil, 31, nil, nil,
+ nil, 32, nil, nil, nil, nil, nil, nil, nil, 5,
+ nil, nil, nil, 16, nil, 25, 27, nil, 37, 29,
+ 48, 49, 46, 47, 42, 43, 44, 45, 40, 41,
+ 39, 38, 5, nil, 6, nil, nil, nil, nil, nil,
+ nil, 37, nil, 48, 49, 46, 47, 42, 43, 44,
+ 45, 40, 41, 39, 38, 97, nil, 6, nil, nil,
+ nil, nil, nil, nil, 37, nil, 48, 49, 46, 47,
+ 42, 43, 44, 45, 40, 41, 39, 38, 37, nil,
+ 48, 49, 46, 47, 42, 43, 44, 45, 40, 41,
+ 39, 38, nil, nil, nil, 37, 90, 48, 49, 46,
+ 47, 42, 43, 44, 45, 40, 41, 39, 38, 37,
+ nil, 48, 49, 46, 47, 42, 43, 44, 45, 40,
+ 41, 39, 38, 37, nil, 48, 49, 46, 47, 42,
+ 43, 44, 45, 40, 41, 39, 38, 37, nil, 48,
+ 49, 46, 47, 42, 43, 44, 45, 40, 41, 39,
+ 38, 37, nil, 48, 49, 46, 47, 42, 43, 44,
+ 45, 40, 41, 39, 38, 37, nil, 48, 49, 46,
+ 47, 42, 43, 44, 45, 40, 41, 39, 38, 37,
+ nil, 48, 49, 46, 47, 42, 43, 44, 45, 40,
+ 41, 39, 38, 37, nil, 48, 49, 46, 47, 42,
+ 43, 44, 45, 40, 41, 39, 38 ]
racc_action_check = [
- 0, 66, 0, 60, 0, 0, 0, 0, 0, 0,
- 0, 0, 90, 2, 35, 0, 35, 35, 35, 35,
- 35, 35, 35, 35, 35, 35, 35, 60, 125, 35,
- 0, 0, 62, 0, 0, 125, 60, 0, 2, 87,
- 71, 93, 87, 71, 35, 35, 55, 35, 35, 122,
- 46, 35, 46, 125, 46, 46, 46, 46, 46, 46,
- 47, 83, 47, 46, 47, 47, 47, 47, 47, 47,
- 55, 98, 15, 47, 122, 15, 55, 98, 116, 46,
- 116, 46, 46, 36, 25, 46, 1, 116, 29, 47,
- 109, 47, 47, 27, 48, 47, 48, 109, 48, 48,
- 48, 48, 48, 48, 31, 116, 31, 48, 31, 31,
- 31, 31, 31, 31, 28, 109, 81, 31, 81, 81,
- 28, 64, 100, 48, 117, 48, 48, 82, 34, 48,
- nil, 117, nil, 31, 53, 31, 31, nil, 49, 31,
- 49, nil, 49, 49, 49, 49, 49, 49, 33, 117,
- 33, 49, 33, 33, 33, 33, 33, 33, 53, 53,
- 79, 33, 79, 79, 79, 79, nil, 49, nil, 49,
- 49, nil, 80, 49, 80, 80, nil, 33, nil, 33,
- 33, nil, 51, 33, 51, nil, 51, 51, 51, 51,
- 51, 51, 37, nil, 37, 51, 37, 37, 37, 37,
- 37, 37, nil, nil, 76, 37, 76, 76, 76, 76,
- nil, 51, 51, 51, 51, nil, nil, 51, nil, nil,
- nil, 37, nil, 37, 37, nil, 39, 37, 39, nil,
- 39, 39, 39, 39, 39, 39, 108, nil, 108, 39,
- 108, 108, 108, 108, 108, 108, nil, nil, 77, 108,
- 77, 77, 77, 77, nil, 39, nil, 39, 39, nil,
- nil, 39, nil, nil, nil, 108, nil, 108, 108, nil,
- 58, 108, 58, nil, 58, 58, 58, 58, 58, 58,
- 41, nil, 41, 58, 41, 41, 41, 41, 41, 41,
- nil, nil, 78, 41, 78, 78, 78, 78, nil, 58,
- nil, 58, 58, nil, nil, 58, nil, nil, nil, 41,
- nil, 41, 41, nil, 42, 41, 42, nil, 42, 42,
- 42, 42, 42, 42, 43, nil, 43, 42, 43, 43,
+ 0, 67, 0, 2, 0, 0, 0, 0, 0, 0,
+ 0, 0, 28, 89, 100, 0, 89, 92, 28, 0,
+ 100, 68, 65, 68, 68, 61, 56, 124, 2, 54,
+ 0, 0, 73, 0, 0, 73, 36, 0, 36, 36,
+ 36, 36, 36, 36, 36, 36, 36, 36, 36, 61,
+ 56, 36, 124, 54, 54, 36, 56, 119, 61, 118,
+ 83, 118, 83, 83, 119, 95, 36, 36, 118, 36,
+ 36, 85, 45, 36, 45, 27, 45, 45, 45, 45,
+ 45, 45, 119, 35, 111, 45, 118, 15, 25, 45,
+ 15, 111, 127, 78, 37, 78, 78, 78, 78, 127,
+ 63, 45, 29, 45, 45, 102, 46, 45, 46, 111,
+ 46, 46, 46, 46, 46, 46, 84, 127, 82, 46,
+ 82, 82, 74, 46, 74, 74, 74, 74, 74, 74,
+ 74, 74, 74, 74, 74, 46, 1, 46, 46, nil,
+ 47, 46, 47, nil, 47, 47, 47, 47, 47, 47,
+ nil, nil, nil, 47, nil, nil, 75, 47, 75, 75,
+ 75, 75, 75, 75, 75, 75, 75, 75, nil, 47,
+ nil, 47, 47, nil, 31, 47, 31, nil, 31, 31,
+ 31, 31, 31, 31, nil, nil, nil, 31, nil, nil,
+ 77, 31, 77, 77, 77, 77, 77, 77, 77, 77,
+ nil, nil, nil, 31, nil, 31, 31, nil, 48, 31,
+ 48, nil, 48, 48, 48, 48, 48, 48, nil, nil,
+ nil, 48, nil, nil, 76, 48, 76, 76, 76, 76,
+ 76, 76, 76, 76, nil, nil, nil, 48, nil, 48,
+ 48, nil, 33, 48, 33, nil, 33, 33, 33, 33,
+ 33, 33, nil, nil, nil, 33, nil, nil, 80, 33,
+ 80, 80, 80, 80, 81, nil, 81, 81, 81, 81,
+ nil, 33, nil, 33, 33, nil, 49, 33, 49, nil,
+ 49, 49, 49, 49, 49, 49, nil, nil, nil, 49,
+ nil, nil, 79, 49, 79, 79, 79, 79, nil, nil,
+ nil, nil, nil, nil, nil, 49, nil, 49, 49, nil,
+ 16, 49, 16, nil, 16, 16, 16, 16, 16, 16,
+ nil, nil, nil, 16, nil, nil, nil, 16, nil, nil,
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, 16,
+ nil, 16, 16, nil, 50, 16, 50, nil, 50, 50,
+ 50, 50, 50, 50, nil, nil, nil, 50, nil, nil,
+ nil, 50, nil, nil, nil, nil, nil, nil, nil, nil,
+ nil, nil, nil, 50, nil, 50, 50, nil, 39, 50,
+ 39, nil, 39, 39, 39, 39, 39, 39, nil, nil,
+ nil, 39, nil, nil, nil, 39, nil, nil, nil, nil,
+ nil, nil, nil, nil, nil, nil, nil, 39, nil, 39,
+ 39, nil, 52, 39, 52, nil, 52, 52, 52, 52,
+ 52, 52, nil, nil, nil, 52, nil, nil, nil, 52,
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
+ nil, 52, 52, 52, 52, nil, 41, 52, 41, nil,
+ 41, 41, 41, 41, 41, 41, nil, nil, nil, 41,
+ nil, nil, nil, 41, nil, nil, nil, nil, nil, nil,
+ nil, nil, nil, nil, nil, 41, nil, 41, 41, nil,
+ 59, 41, 59, nil, 59, 59, 59, 59, 59, 59,
+ nil, nil, nil, 59, nil, nil, nil, 59, nil, nil,
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, 59,
+ nil, 59, 59, nil, 43, 59, 43, nil, 43, 43,
43, 43, 43, 43, nil, nil, nil, 43, nil, nil,
- nil, nil, nil, 42, nil, 42, 42, nil, nil, 42,
- nil, nil, nil, 43, nil, 43, 43, nil, 44, 43,
- 44, nil, 44, 44, 44, 44, 44, 44, nil, nil,
- 124, 44, 124, 124, 124, 124, 124, 124, 124, 124,
- nil, nil, nil, 124, nil, nil, nil, 44, nil, 44,
- 44, nil, nil, 44, nil, nil, nil, nil, 124, 124,
- nil, 124, 124, nil, 26, 124, 26, 26, 26, 26,
- 26, 26, 26, 26, nil, nil, 89, 26, 89, 89,
- 89, 89, 89, 89, 89, 89, nil, nil, nil, 89,
- nil, 26, nil, 26, nil, 26, 26, 26, nil, 26,
- nil, nil, nil, nil, 89, 89, nil, 89, 89, nil,
- 16, 89, 16, nil, 16, 16, 16, 16, 16, 16,
- nil, nil, 94, 16, 94, 94, 94, 94, 94, 94,
- 94, 94, nil, nil, nil, 94, nil, nil, nil, 16,
- nil, 16, 16, nil, nil, 16, nil, nil, nil, nil,
- nil, 94, nil, 94, 94, nil, 40, 94, 40, nil,
- 40, 40, 40, 40, 40, 40, 101, nil, 101, 40,
- 101, 101, 101, 101, 101, 101, nil, nil, nil, 101,
- nil, nil, nil, nil, nil, 40, nil, 40, 40, nil,
- nil, 40, nil, nil, nil, 101, nil, 101, 101, nil,
- 45, 101, 45, nil, 45, 45, 45, 45, 45, 45,
- nil, nil, 103, 45, 103, 103, 103, 103, 103, 103,
- 103, 103, nil, nil, nil, 103, nil, nil, nil, 45,
- nil, 45, 45, nil, nil, 45, nil, nil, nil, nil,
- 103, 103, nil, 103, 103, nil, 38, 103, 38, nil,
- 38, 38, 38, 38, 38, 38, nil, nil, 104, 38,
- 104, 104, 104, 104, 104, 104, 104, 104, nil, nil,
- nil, 104, nil, nil, nil, 38, nil, 38, 38, nil,
- nil, 38, nil, nil, nil, nil, 104, 104, nil, 104,
- 104, nil, 32, 104, 32, nil, 32, 32, 32, 32,
- 32, 32, 105, nil, 105, 32, 105, 105, 105, 105,
- 105, 105, nil, nil, nil, 105, nil, nil, nil, nil,
- nil, 32, nil, 32, 32, nil, nil, 32, nil, 67,
- nil, 105, nil, 105, 105, nil, nil, 105, 67, nil,
- 67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
- 67, 67, 68, nil, 67, nil, nil, nil, nil, nil,
- nil, 68, nil, 68, 68, 68, 68, 68, 68, 68,
- 68, 68, 68, 68, 68, 57, nil, 68, nil, nil,
- nil, nil, nil, nil, 57, nil, 57, 57, 57, 57,
- 57, 57, 57, 57, 57, 57, 57, 57, 52, nil,
- 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
- 52, 52, nil, nil, nil, 96, 52, 96, 96, 96,
- 96, 96, 96, 96, 96, 96, 96, 96, 96, 3,
+ nil, 43, nil, nil, nil, nil, nil, nil, nil, nil,
+ nil, nil, nil, 43, nil, 43, 43, nil, 126, 43,
+ 126, 126, 126, 126, 126, 126, 126, 126, nil, nil,
+ nil, 126, nil, nil, nil, 126, nil, nil, nil, nil,
+ nil, nil, nil, nil, nil, nil, 126, 126, nil, 126,
+ 126, nil, 110, 126, 110, nil, 110, 110, 110, 110,
+ 110, 110, nil, nil, nil, 110, nil, nil, nil, 110,
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
+ nil, 110, nil, 110, 110, nil, 91, 110, 91, 91,
+ 91, 91, 91, 91, 91, 91, nil, nil, nil, 91,
+ nil, nil, nil, 91, nil, nil, nil, nil, nil, nil,
+ nil, nil, nil, nil, 91, 91, nil, 91, 91, nil,
+ 32, 91, 32, nil, 32, 32, 32, 32, 32, 32,
+ nil, nil, nil, 32, nil, nil, nil, 32, nil, nil,
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, 32,
+ nil, 32, 32, nil, 96, 32, 96, 96, 96, 96,
+ 96, 96, 96, 96, nil, nil, nil, 96, nil, nil,
+ nil, 96, nil, nil, nil, nil, nil, nil, nil, nil,
+ nil, nil, nil, 96, nil, 96, 96, nil, 38, 96,
+ 38, nil, 38, 38, 38, 38, 38, 38, nil, nil,
+ nil, 38, nil, nil, nil, 38, nil, nil, nil, nil,
+ nil, nil, nil, nil, nil, nil, nil, 38, nil, 38,
+ 38, nil, 103, 38, 103, nil, 103, 103, 103, 103,
+ 103, 103, nil, nil, nil, 103, nil, nil, nil, 103,
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
+ nil, 103, nil, 103, 103, nil, 42, 103, 42, nil,
+ 42, 42, 42, 42, 42, 42, nil, nil, nil, 42,
+ nil, nil, nil, 42, nil, nil, nil, nil, nil, nil,
+ nil, nil, nil, nil, nil, 42, nil, 42, 42, nil,
+ 105, 42, 105, 105, 105, 105, 105, 105, 105, 105,
+ nil, nil, nil, 105, nil, nil, nil, 105, nil, nil,
+ nil, nil, nil, nil, nil, nil, nil, nil, 105, 105,
+ nil, 105, 105, nil, 26, 105, 26, 26, 26, 26,
+ 26, 26, 26, 26, nil, nil, nil, 26, nil, nil,
+ nil, 26, nil, nil, nil, nil, nil, nil, nil, nil,
+ nil, 26, nil, 26, nil, 26, 26, 26, 106, 26,
+ 106, 106, 106, 106, 106, 106, 106, 106, nil, nil,
+ nil, 106, nil, nil, nil, 106, nil, nil, nil, nil,
+ nil, nil, nil, nil, nil, nil, 106, 106, nil, 106,
+ 106, nil, 40, 106, 40, nil, 40, 40, 40, 40,
+ 40, 40, nil, nil, nil, 40, nil, nil, nil, 40,
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
+ nil, 40, nil, 40, 40, nil, 107, 40, 107, nil,
+ 107, 107, 107, 107, 107, 107, nil, nil, nil, 107,
+ nil, nil, nil, 107, nil, nil, nil, nil, nil, nil,
+ nil, nil, nil, nil, nil, 107, nil, 107, 107, nil,
+ 34, 107, 34, nil, 34, 34, 34, 34, 34, 34,
+ nil, nil, nil, 34, nil, nil, nil, 34, nil, nil,
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, 34,
+ nil, 34, 34, nil, 44, 34, 44, nil, 44, 44,
+ 44, 44, 44, 44, nil, nil, nil, 44, nil, nil,
+ nil, 44, nil, nil, nil, nil, nil, nil, nil, 69,
+ nil, nil, nil, 44, nil, 44, 44, nil, 69, 44,
+ 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
+ 69, 69, 70, nil, 69, nil, nil, nil, nil, nil,
+ nil, 70, nil, 70, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 58, nil, 70, nil, nil,
+ nil, nil, nil, nil, 58, nil, 58, 58, 58, 58,
+ 58, 58, 58, 58, 58, 58, 58, 58, 53, nil,
+ 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
+ 53, 53, nil, nil, nil, 98, 53, 98, 98, 98,
+ 98, 98, 98, 98, 98, 98, 98, 98, 98, 3,
nil, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 84, nil, 84, 84, 84, 84, 84,
- 84, 84, 84, 84, 84, 84, 84, 115, nil, 115,
- 115, 115, 115, 115, 115, 115, 115, 115, 115, 115,
- 115, 70, nil, 70, 70, 70, 70, 70, 70, 70,
- 70, 70, 70, 70, 70, 118, nil, 118, 118, 118,
- 118, 118, 118, 118, 118, 118, 118, 118, 118, 85,
- nil, 85, 85, 85, 85, 85, 85, 85, 85, 85,
- 85, 85, 85, 119, nil, 119, 119, 119, 119, 119,
- 119, 119, 119, 119, 119, 119, 119, 72, nil, 72,
- 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
- 73, nil, 73, 73, 73, 73, 73, 73, 73, 73,
- 73, 73, 74, nil, 74, 74, 74, 74, 74, 74,
- 74, 74, 75, nil, 75, 75, 75, 75, 75, 75,
- 75, 75 ]
+ 3, 3, 3, 86, nil, 86, 86, 86, 86, 86,
+ 86, 86, 86, 86, 86, 86, 86, 87, nil, 87,
+ 87, 87, 87, 87, 87, 87, 87, 87, 87, 87,
+ 87, 120, nil, 120, 120, 120, 120, 120, 120, 120,
+ 120, 120, 120, 120, 120, 72, nil, 72, 72, 72,
+ 72, 72, 72, 72, 72, 72, 72, 72, 72, 121,
+ nil, 121, 121, 121, 121, 121, 121, 121, 121, 121,
+ 121, 121, 121, 117, nil, 117, 117, 117, 117, 117,
+ 117, 117, 117, 117, 117, 117, 117 ]
racc_action_pointer = [
- 0, 86, 8, 755, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, nil, nil, 44, 448, nil, nil, nil,
- nil, nil, nil, nil, nil, 73, 402, 88, 109, 83,
- nil, 102, 630, 146, 128, 14, 72, 190, 584, 224,
- 494, 278, 312, 322, 356, 538, 48, 58, 92, 136,
- nil, 180, 724, 129, nil, 41, nil, 710, 268, nil,
- -2, nil, -4, nil, 110, nil, -13, 664, 687, nil,
- 797, 12, 853, 866, 878, 888, 190, 234, 278, 146,
- 158, 102, 113, 47, 769, 825, nil, 10, nil, 414,
- 1, nil, nil, 6, 460, nil, 741, nil, 66, nil,
- 84, 504, nil, 550, 596, 640, nil, nil, 234, 85,
- nil, nil, nil, nil, nil, 783, 75, 119, 811, 839,
- nil, nil, 44, nil, 368, 23, nil ]
+ 0, 136, -2, 1135, nil, nil, nil, nil, nil, nil,
+ nil, nil, nil, nil, nil, 59, 308, nil, nil, nil,
+ nil, nil, nil, nil, nil, 77, 852, 70, 7, 97,
+ nil, 172, 648, 240, 988, 83, 36, 83, 716, 376,
+ 920, 444, 784, 512, 1022, 70, 104, 138, 206, 274,
+ 342, nil, 410, 1104, 24, nil, 21, nil, 1090, 478,
+ nil, 20, nil, 64, nil, 11, nil, -13, 7, 1044,
+ 1067, nil, 1191, 4, 108, 142, 210, 176, 79, 278,
+ 244, 250, 104, 46, 102, 57, 1149, 1163, nil, -16,
+ nil, 614, 6, nil, nil, 30, 682, nil, 1121, nil,
+ 9, nil, 67, 750, nil, 818, 886, 954, nil, nil,
+ 580, 79, nil, nil, nil, nil, nil, 1219, 56, 52,
+ 1177, 1205, nil, nil, 22, nil, 546, 87, nil ]
racc_action_default = [
- -53, -80, -2, -3, -6, -7, -8, -9, -10, -11,
+ -53, -81, -2, -3, -6, -7, -8, -9, -10, -11,
-12, -13, -14, -15, -16, -17, -53, -19, -20, -21,
- -22, -23, -24, -25, -26, -74, -53, -29, -40, -46,
- -50, -53, -53, -53, -80, -53, -80, -53, -53, -53,
+ -22, -23, -24, -25, -26, -75, -53, -29, -40, -46,
+ -50, -53, -53, -53, -53, -81, -53, -81, -53, -53,
-53, -53, -53, -53, -53, -53, -53, -53, -53, -53,
- -55, -53, -80, -80, -75, -80, -34, -36, -53, -30,
- -80, -41, -80, -44, -80, -47, -73, -80, -80, 127,
- -4, -54, -61, -62, -63, -64, -65, -66, -67, -68,
- -69, -70, -71, -72, -51, -59, -57, -80, -18, -53,
- -80, -28, -31, -80, -53, -38, -37, -39, -80, -48,
- -80, -53, -45, -53, -53, -53, -56, -58, -53, -80,
- -76, -32, -35, -42, -49, -43, -80, -80, -52, -60,
- -27, -77, -80, -79, -53, -80, -78 ]
+ -53, -55, -53, -81, -81, -76, -81, -34, -36, -53,
+ -30, -81, -41, -81, -44, -81, -47, -73, -74, -81,
+ -81, 129, -4, -54, -61, -62, -63, -64, -65, -66,
+ -67, -68, -69, -70, -71, -72, -51, -59, -57, -81,
+ -18, -53, -81, -28, -31, -81, -53, -38, -37, -39,
+ -81, -48, -81, -53, -45, -53, -53, -53, -56, -58,
+ -53, -81, -77, -32, -35, -42, -49, -43, -81, -81,
+ -52, -60, -27, -78, -81, -80, -53, -81, -79 ]
racc_goto_table = [
- 2, 52, 35, 61, 56, 50, 55, 97, 53, 1,
- 54, 57, 87, 63, 91, 60, 66, 67, 68, nil,
- 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
- 80, 81, 82, 83, 84, nil, 85, nil, nil, nil,
- nil, nil, nil, 96, nil, nil, nil, nil, nil, 102,
- nil, nil, nil, 89, nil, nil, nil, nil, nil, nil,
- nil, 106, nil, nil, nil, nil, nil, 103, 104, nil,
- nil, nil, 112, 113, nil, 110, nil, nil, nil, 57,
- nil, nil, nil, 63, nil, nil, 115, nil, nil, 109,
- 118, nil, nil, 119, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, 116, 117, nil, nil, nil, nil, 35,
- nil, nil, nil, nil, nil, nil, 35, 35, nil, nil,
- nil, nil, 124, nil, 125, 35 ]
+ 2, 53, 36, 62, 57, 51, 56, 99, 54, 1,
+ 55, 58, 89, 64, 93, 61, 67, 68, 69, 70,
+ nil, 72, 73, 74, 75, 76, 77, 78, 79, 80,
+ 81, 82, 83, 84, 85, 86, nil, 87, nil, nil,
+ nil, nil, nil, nil, 98, nil, nil, nil, nil, nil,
+ 104, nil, nil, nil, 91, nil, nil, nil, nil, nil,
+ nil, nil, nil, 108, nil, nil, nil, nil, nil, 105,
+ 106, nil, nil, nil, 114, 115, nil, 112, nil, nil,
+ nil, 58, nil, nil, nil, 64, nil, nil, 117, nil,
+ nil, 111, 120, nil, nil, 121, nil, nil, nil, nil,
+ nil, nil, nil, nil, nil, 118, 119, nil, nil, nil,
+ nil, 36, nil, nil, nil, nil, nil, nil, 36, 36,
+ nil, nil, nil, nil, 126, nil, 127, 36 ]
racc_goto_check = [
2, 3, 4, 25, 21, 27, 19, 24, 17, 1,
- 13, 3, 28, 13, 20, 23, 3, 3, 3, nil,
- 3, 13, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, nil, 3, nil, nil, nil,
- nil, nil, nil, 3, nil, nil, nil, nil, nil, 13,
- nil, nil, nil, 4, nil, nil, nil, nil, nil, nil,
- nil, 27, nil, nil, nil, nil, nil, 4, 4, nil,
- nil, nil, 21, 25, nil, 13, nil, nil, nil, 3,
- nil, nil, nil, 13, nil, nil, 3, nil, nil, 2,
- 3, nil, nil, 3, nil, nil, nil, nil, nil, nil,
- nil, nil, nil, 2, 2, nil, nil, nil, nil, 4,
- nil, nil, nil, nil, nil, nil, 4, 4, nil, nil,
- nil, nil, 4, nil, 2, 4 ]
+ 13, 3, 28, 13, 20, 23, 3, 3, 3, 3,
+ nil, 3, 13, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, nil, 3, nil, nil,
+ nil, nil, nil, nil, 3, nil, nil, nil, nil, nil,
+ 13, nil, nil, nil, 4, nil, nil, nil, nil, nil,
+ nil, nil, nil, 27, nil, nil, nil, nil, nil, 4,
+ 4, nil, nil, nil, 21, 25, nil, 13, nil, nil,
+ nil, 3, nil, nil, nil, 13, nil, nil, 3, nil,
+ nil, 2, 3, nil, nil, 3, nil, nil, nil, nil,
+ nil, nil, nil, nil, nil, 2, 2, nil, nil, nil,
+ nil, 4, nil, nil, nil, nil, nil, nil, 4, 4,
+ nil, nil, nil, nil, 4, nil, 2, 4 ]
racc_goto_pointer = [
nil, 9, 0, -15, 0, nil, nil, nil, nil, nil,
nil, nil, nil, -15, nil, nil, nil, -17, nil, -20,
- -41, -22, nil, -13, -53, -25, nil, -10, -39 ]
+ -42, -22, nil, -13, -54, -25, nil, -10, -40 ]
racc_goto_default = [
nil, nil, nil, 3, 4, 7, 8, 9, 10, 11,
12, 13, 14, 15, 19, 20, 21, nil, 26, nil,
- nil, nil, 28, nil, nil, nil, 62, nil, nil ]
+ nil, nil, 28, nil, nil, nil, 63, nil, nil ]
racc_reduce_table = [
0, 0, :racc_error,
@@ -358,16 +424,17 @@ def parse(code)
3, 47, :_reduce_71,
3, 47, :_reduce_72,
2, 47, :_reduce_73,
- 0, 56, :_reduce_74,
- 1, 56, :_reduce_75,
- 3, 56, :_reduce_76,
- 5, 49, :_reduce_77,
- 8, 49, :_reduce_78,
- 5, 50, :_reduce_79 ]
+ 2, 47, :_reduce_74,
+ 0, 56, :_reduce_75,
+ 1, 56, :_reduce_76,
+ 3, 56, :_reduce_77,
+ 5, 49, :_reduce_78,
+ 8, 49, :_reduce_79,
+ 5, 50, :_reduce_80 ]
-racc_reduce_n = 80
+racc_reduce_n = 81
-racc_shift_n = 127
+racc_shift_n = 129
racc_token_table = {
false => 0,
@@ -907,48 +974,55 @@ def _reduce_72(val, _values, result)
module_eval(<<'.,.,', 'noscript.y', 200)
def _reduce_73(val, _values, result)
- result = CallNode.new(lineno, val[1], val[0], [])
+ result = CallNode.new(lineno, val[1], '@!', [])
result
end
.,.,
-module_eval(<<'.,.,', 'noscript.y', 204)
+module_eval(<<'.,.,', 'noscript.y', 201)
def _reduce_74(val, _values, result)
- result = []
+ result = CallNode.new(lineno, val[1], '@-', [])
result
end
.,.,
module_eval(<<'.,.,', 'noscript.y', 205)
def _reduce_75(val, _values, result)
- result = [val[0].name]
+ result = []
result
end
.,.,
module_eval(<<'.,.,', 'noscript.y', 206)
def _reduce_76(val, _values, result)
- result = val[0] << val[2].name
+ result = [val[0].name]
result
end
.,.,
-module_eval(<<'.,.,', 'noscript.y', 212)
+module_eval(<<'.,.,', 'noscript.y', 207)
def _reduce_77(val, _values, result)
- result = IfNode.new(lineno, val[1], val[3], nil)
+ result = val[0] << val[2].name
result
end
.,.,
-module_eval(<<'.,.,', 'noscript.y', 217)
+module_eval(<<'.,.,', 'noscript.y', 213)
def _reduce_78(val, _values, result)
- result = IfNode.new(lineno, val[1], val[3], val[6])
+ result = IfNode.new(lineno, val[1], val[3], nil)
result
end
.,.,
-module_eval(<<'.,.,', 'noscript.y', 223)
+module_eval(<<'.,.,', 'noscript.y', 218)
def _reduce_79(val, _values, result)
+ result = IfNode.new(lineno, val[1], val[3], val[6])
+ result
+ end
+.,.,
+
+module_eval(<<'.,.,', 'noscript.y', 224)
+ def _reduce_80(val, _values, result)
result = WhileNode.new(lineno, val[1], val[3])
result
end
View
5 lib/noscript/bootstrap.rb → lib/noscript/runtime.rb
@@ -17,9 +17,11 @@ def noscript_send(name, *args)
end
noscript_alias [:==, :"!="]
+ noscript_def("@!") { !self }
noscript_alias :nil?
noscript_alias :inspect
+ noscript_def("puts") { |*args| send :puts, *args } # Because it's private
noscript_def("respond to?") { |name| respond_to? "noscript:#{name}"}
end
@@ -95,7 +97,8 @@ def initialize(blk_env)
end
end
class Fixnum
- noscript_alias [:+, :-, :<, :>]
+ noscript_alias [:+, :-, :*, :/, :<, :>, :<=, :>=]
+ noscript_def("@-") { -self }
end
class Array
View
3  lib/noscript/signature.rb
@@ -0,0 +1,3 @@
+# This file is generated by `rake signature`. The signature
+# is used to ensure that only current compiled files are loaded.
+Noscript::Signature = Rubinius::Signature ^ 13737641176025360115
View
28 lib/noscript/stages.rb
@@ -0,0 +1,28 @@
+module Noscript
+ class Stage
+ # This stage takes a noscript filename and produces a ruby array
+ # containing representation of the source.
+ class NoscriptFile < Rubinius::Compiler::Stage
+ stage :noscript_file
+ next_stage NoscriptAST
+ attr_reader :filename, :line
+ attr_accessor :print
+
+ def initialize(compiler, last)
+ super
+ @print = Compiler::Print.new
+ compiler.parser = self
+ end
+
+ def input(filename, line = 1)
+ @filename = filename
+ @line = line
+ end
+
+ def run
+ @output = File.read(@filename)
+ run_next
+ end
+ end
+ end
+end
View
56 test/compiler_test.rb
@@ -2,100 +2,108 @@
module Noscript
class CompilerTest < MiniTest::Unit::TestCase
- def setup
- @compiler = Compiler.new
+ def compile(code)
+ Noscript.eval_noscript(code)
end
def test_compile_integer_literal
- assert_equal 1, @compiler.compile("1").call
+ assert_equal 1, compile("1")
+ end
+
+ def test_compile_unary_minus
+ assert_equal -1, compile("-1")
end
def test_compile_string_literal
- assert_equal '1', @compiler.compile("'1'").call
+ assert_equal '1', compile("'1'")
end
def test_compile_assignment
- assert_equal 1, @compiler.compile("foo = 1; foo").call
+ assert_equal 1, compile("foo = 1; foo")
end
def test_compile_array_literal
- assert_equal 1, @compiler.compile("[1,2].at(0)").call
+ assert_equal 1, compile("[1,2].at(0)")
end
def test_compile_tuple_literal
- assert_equal({'a' => true, 'b' => false}, @compiler.compile("{a: true, b: false}").call)
+ assert_equal({'a' => true, 'b' => false}, compile("{a: true, b: false}"))
end
def test_compile_tuple_literal_as_an_expression
- assert_equal(['a', 'b'], @compiler.compile("{a: true, b: false}.keys()").call)
+ assert_equal(['a', 'b'], compile("{a: true, b: false}.keys()"))
end
def test_compile_function_without_arguments
- assert_equal 3, @compiler.compile("foo = ->; 3; end; foo()").call
+ assert_equal 3, compile("foo = ->; 3; end; foo()")
end
def test_compile_function_with_unused_arguments
- assert_equal 3, @compiler.compile("foo = -> a; 3; end; foo(5)").call
+ assert_equal 3, compile("foo = -> a; 3; end; foo(5)")
end
def test_compile_function_with_used_arguments
- assert_equal 10, @compiler.compile("foo = -> a; a + a; end; foo(5)").call
+ assert_equal 10, compile("foo = -> a; a + a; end; foo(5)")
end
def test_compile_function_with_multiple_arguments
- assert_equal 7, @compiler.compile("foo = -> a, b, c; b + c; end; foo(5, 4, 3)").call
+ assert_equal 7, compile("foo = -> a, b, c; b + c; end; foo(5, 4, 3)")
+ end
+
+ def test_compile_function_as_an_object_slot
+ assert_equal 4, compile("foo = Object.clone(); foo.bar = ->; 4; end; foo.bar()")
end
def test_compile_true
- assert_equal true, @compiler.compile("true").call
+ assert_equal true, compile("true")
end
def test_compile_false
- assert_equal false, @compiler.compile("false").call
+ assert_equal false, compile("false")
end
def test_compile_nil
- assert_equal nil, @compiler.compile("nil").call
+ assert_equal nil, compile("nil")
end
def test_compile_call
- assert_equal "1", @compiler.compile("1.inspect()").call
+ assert_equal "1", compile("1.inspect()")
end
def test_compile_local_assign
- assert_equal 3, @compiler.compile("a = 3").call
+ assert_equal 3, compile("a = 3")
end
def test_compile_object_clone
- obj = @compiler.compile("Object.clone()").call
+ obj = compile("Object.clone()")
assert_kind_of Runtime::ObjectType, obj
assert_equal Runtime::Object, obj.prototype
end
def test_compile_object_clone_with_properties
- obj = @compiler.compile("Object.clone({a: 1})").call
+ obj = compile("Object.clone({a: 1})")
assert_equal 1, obj.get(:a)
end
def test_compile_slot_get
- assert_equal 1, @compiler.compile("obj = Object.clone({a: 1}); obj.a").call
+ assert_equal 1, compile("obj = Object.clone({a: 1}); obj.a")
end
def test_compile_slot_assign
- obj = @compiler.compile("foo = Object.clone(); foo.a = 3; foo").call
+ obj = compile("foo = Object.clone(); foo.a = 3; foo")
assert_equal 3, obj.get(:a)
end
def test_compile_if
- assert_equal 1, @compiler.compile("if true; 1; end").call
+ assert_equal 1, compile("if true; 1; end")
end
def test_compile_if_else
- assert_equal 2, @compiler.compile("if false; 1; else; 2; end").call
+ assert_equal 2, compile("if false; 1; else; 2; end")
end
def test_compile_while
- assert_equal 10, @compiler.compile("a = 3; while a < 10; a = a + 1; end; a").call
+ assert_equal 10, compile("a = 3; while a < 10; a = a + 1; end; a")
end
end
end
View
8 test/integration_test.rb
@@ -3,8 +3,8 @@
module Noscript
class IntegrationTest < MiniTest::Unit::TestCase
- def setup
- @compiler = Compiler.new
+ def compile(code)
+ Noscript.eval_noscript(code)
end
# def test_hello_world
@@ -104,7 +104,7 @@ def test_conditionals
end
"""
].each do |code|
- assert_equal 'ok', @compiler.compile(code).call
+ assert_equal 'ok', compile(code)
end
end
@@ -120,7 +120,7 @@ def test_while
foo
"""
].each do |code|
- assert_equal 0, @compiler.compile(code).call
+ assert_equal 0, compile(code)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.