better error reporting for parser

This commit is contained in:
Torsten Ruger 2015-11-19 10:10:13 +02:00
parent 249f43ad34
commit 4871a52d37
6 changed files with 11 additions and 10 deletions

View File

@ -17,7 +17,7 @@ module Register
# return is stored in return_value
# (this method returns a new method off course, like all builtin)
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"
#Load self by "calling" on_name
me = compiler.process( s(:name , :self) )
@ -35,7 +35,7 @@ module Register
# no return
def set_internal_word context
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"
#Load self by "calling" on_name
me = compiler.process( s(:name , :self) )

View File

@ -70,7 +70,7 @@ module Register
end
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)
#puts parts.inspect
Soml.compile( parts )

View File

@ -68,11 +68,12 @@ module Soml
@clazz = clazz
raise "create_method #{method_name}.#{method_name.class}" unless method_name.is_a? Symbol
arguments = []
args.each do | arg , name |
unless arg.is_a? Parfait::Variable
arg = Parfait::Variable.new arg , name.to_sym
if( args.is_a? Array)
arguments = args
else
args.each do | name , type |
arguments << Parfait::Variable.new( type , name.to_sym)
end
arguments << arg
end
@method = clazz.create_instance_method( method_name , Parfait.new_list(arguments))
self

View File

@ -5,7 +5,7 @@ module Ticker
def setup
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)
#puts parts.inspect
Soml.compile( parts )

View File

@ -19,7 +19,7 @@ module ExpressionHelper
machine.boot unless machine.booted
parser = Parser::Salama.new
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)
#puts parts.inspect
compiler = Soml::Compiler.new

View File

@ -21,7 +21,7 @@ class TestRunner < MiniTest::Test
string = File.read(file)
parser = Parser::Salama.new
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
parts = Parser::Transform.new.apply(syntax)
# file is a list of statements, all but the last must be a function