From 6e729543981064c0d447ba40e54b9eb0e675cb28 Mon Sep 17 00:00:00 2001 From: subarutaro Date: Fri, 7 Aug 2020 21:11:45 +0900 Subject: [PATCH] modify a bug on parse error message --- src/kernelparser.rb | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/kernelparser.rb b/src/kernelparser.rb index 04d7a46..66e5f69 100644 --- a/src/kernelparser.rb +++ b/src/kernelparser.rb @@ -183,10 +183,25 @@ def next_token def on_error(id,val,stack) - lineno = get_lineno(val) - line = get_line(val) - warning = "parse error :line #{lineno}: #{line}" - for i in 1..warning.index(val) + #lineno = get_lineno(val) + #line = get_line(val) + line0 = [] + $used_q.reverse_each{ |v| + break if v[1] == :EOL + line0.push(v[1]) + } + line0 = "parse error: " + line0.reverse.join('') + + line1 = [] + @q.each{ |v| + break if v[1] == :EOL + line1.push(v[1]) + } + line1 = line1.join('') + + #warning = "parse error :line #{lineno}: #{line}" + warning = line0 + line1 + for i in 1..line0.length warning += " " end warning += "^"