better error reporting for parser
This commit is contained in:
parent
249f43ad34
commit
4871a52d37
@ -17,7 +17,7 @@ module Register
|
|||||||
# return is stored in return_value
|
# return is stored in return_value
|
||||||
# (this method returns a new method off course, like all builtin)
|
# (this method returns a new method off course, like all builtin)
|
||||||
def get_internal_word context
|
def get_internal_word context
|
||||||
compiler = Soml::Compiler.new.create_method(:Object , :get_internal_word , {:Integer => :index}).init_method
|
compiler = Soml::Compiler.new.create_method(:Object , :get_internal_word , {:index => :Integer}).init_method
|
||||||
source = "get_internal_word"
|
source = "get_internal_word"
|
||||||
#Load self by "calling" on_name
|
#Load self by "calling" on_name
|
||||||
me = compiler.process( s(:name , :self) )
|
me = compiler.process( s(:name , :self) )
|
||||||
@ -35,7 +35,7 @@ module Register
|
|||||||
# no return
|
# no return
|
||||||
def set_internal_word context
|
def set_internal_word context
|
||||||
compiler = Soml::Compiler.new.create_method(:Object , :set_internal_word ,
|
compiler = Soml::Compiler.new.create_method(:Object , :set_internal_word ,
|
||||||
{:Integer => :index, :Object => :value} ).init_method
|
{:index => :Integer, :value => :Object} ).init_method
|
||||||
source = "set_internal_word"
|
source = "set_internal_word"
|
||||||
#Load self by "calling" on_name
|
#Load self by "calling" on_name
|
||||||
me = compiler.process( s(:name , :self) )
|
me = compiler.process( s(:name , :self) )
|
||||||
|
@ -70,7 +70,7 @@ module Register
|
|||||||
end
|
end
|
||||||
|
|
||||||
def parse_and_compile bytes
|
def parse_and_compile bytes
|
||||||
syntax = Parser::Salama.new.parse_with_debug(bytes)
|
syntax = Parser::Salama.new.parse_with_debug(bytes, reporter: Parslet::ErrorReporter::Deepest.new)
|
||||||
parts = Parser::Transform.new.apply(syntax)
|
parts = Parser::Transform.new.apply(syntax)
|
||||||
#puts parts.inspect
|
#puts parts.inspect
|
||||||
Soml.compile( parts )
|
Soml.compile( parts )
|
||||||
|
@ -68,11 +68,12 @@ module Soml
|
|||||||
@clazz = clazz
|
@clazz = clazz
|
||||||
raise "create_method #{method_name}.#{method_name.class}" unless method_name.is_a? Symbol
|
raise "create_method #{method_name}.#{method_name.class}" unless method_name.is_a? Symbol
|
||||||
arguments = []
|
arguments = []
|
||||||
args.each do | arg , name |
|
if( args.is_a? Array)
|
||||||
unless arg.is_a? Parfait::Variable
|
arguments = args
|
||||||
arg = Parfait::Variable.new arg , name.to_sym
|
else
|
||||||
|
args.each do | name , type |
|
||||||
|
arguments << Parfait::Variable.new( type , name.to_sym)
|
||||||
end
|
end
|
||||||
arguments << arg
|
|
||||||
end
|
end
|
||||||
@method = clazz.create_instance_method( method_name , Parfait.new_list(arguments))
|
@method = clazz.create_instance_method( method_name , Parfait.new_list(arguments))
|
||||||
self
|
self
|
||||||
|
@ -5,7 +5,7 @@ module Ticker
|
|||||||
|
|
||||||
def setup
|
def setup
|
||||||
machine = Register.machine.boot
|
machine = Register.machine.boot
|
||||||
syntax = Parser::Salama.new.parse_with_debug(@string_input)
|
syntax = Parser::Salama.new.parse_with_debug(@string_input, reporter: Parslet::ErrorReporter::Deepest.new)
|
||||||
parts = Parser::Transform.new.apply(syntax)
|
parts = Parser::Transform.new.apply(syntax)
|
||||||
#puts parts.inspect
|
#puts parts.inspect
|
||||||
Soml.compile( parts )
|
Soml.compile( parts )
|
||||||
|
@ -19,7 +19,7 @@ module ExpressionHelper
|
|||||||
machine.boot unless machine.booted
|
machine.boot unless machine.booted
|
||||||
parser = Parser::Salama.new
|
parser = Parser::Salama.new
|
||||||
parser = parser.send @root
|
parser = parser.send @root
|
||||||
syntax = parser.parse_with_debug(@string_input)
|
syntax = parser.parse_with_debug(@string_input, reporter: Parslet::ErrorReporter::Deepest.new)
|
||||||
parts = Parser::Transform.new.apply(syntax)
|
parts = Parser::Transform.new.apply(syntax)
|
||||||
#puts parts.inspect
|
#puts parts.inspect
|
||||||
compiler = Soml::Compiler.new
|
compiler = Soml::Compiler.new
|
||||||
|
@ -21,7 +21,7 @@ class TestRunner < MiniTest::Test
|
|||||||
string = File.read(file)
|
string = File.read(file)
|
||||||
parser = Parser::Salama.new
|
parser = Parser::Salama.new
|
||||||
object_space = Register::Program.new "Arm"
|
object_space = Register::Program.new "Arm"
|
||||||
syntax = parser.parse_with_debug(string)
|
syntax = parser.parse_with_debug(string, reporter: Parslet::ErrorReporter::Deepest.new)
|
||||||
assert syntax
|
assert syntax
|
||||||
parts = Parser::Transform.new.apply(syntax)
|
parts = Parser::Transform.new.apply(syntax)
|
||||||
# file is a list of statements, all but the last must be a function
|
# file is a list of statements, all but the last must be a function
|
||||||
|
Loading…
Reference in New Issue
Block a user