eturem 0.4.0 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,56 @@
1
+ # coding: utf-8
2
+
3
+ module Eturem
4
+ module ArgumentErrorExt
5
+ include ExceptionExt
6
+
7
+ def eturem_message()
8
+ given = nil
9
+ if @eturem_message.include?("wrong number of arguments")
10
+ if @eturem_message.match(/\(given (?<given>\d+), expected (?<expected>[^)]+)\)/)
11
+ given = Regexp.last_match(:given).to_i
12
+ expected = Regexp.last_match(:expected)
13
+ elsif @eturem_message.match(/\((?<given>\d+) for (?<expected>[^)]+)\)/)
14
+ given = Regexp.last_match(:given).to_i
15
+ expected = Regexp.last_match(:expected)
16
+ end
17
+ end
18
+
19
+ if given
20
+ eturem_wrong_number_of_arguments(given, expected)
21
+ elsif @eturem_message.match(/too big/)
22
+ eturem_argument_too_big
23
+ else
24
+ eturem_other_argument_error
25
+ end
26
+ super
27
+ end
28
+
29
+ def eturem_wrong_number_of_arguments(given, expected)
30
+ @eturem_message_ja = "引数の数が正しくありません。「#{@eturem_method}」は本来"
31
+ case expected
32
+ when "0"
33
+ @eturem_message_ja += "引数が不要です"
34
+ when /^(\d+)\.\.(\d+)$/
35
+ @eturem_message_ja += " #{$1}~#{$2} 個の引数を取ります"
36
+ when /^(\d+)\+$/
37
+ @eturem_message_ja += " #{$1} 個以上の引数を取ります"
38
+ else
39
+ @eturem_message_ja += " #{expected} 個の引数を取ります"
40
+ end
41
+ if given == 0
42
+ @eturem_message_ja += "が、引数が1つも渡されていません。"
43
+ else
44
+ @eturem_message_ja += "が、#{given} 個の引数が渡されています。"
45
+ end
46
+ end
47
+
48
+ def eturem_argument_too_big()
49
+ @eturem_message_ja = "「#{@eturem_method}」への引数が大きすぎます。"
50
+ end
51
+
52
+ def eturem_other_argument_error()
53
+ @eturem_message_ja = "「#{@eturem_method}」への引数が正しくありません。"
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,13 @@
1
+ module Eturem
2
+ module DXRubyErrorExt
3
+ include ExceptionExt
4
+
5
+ def eturem_message()
6
+ case @eturem_message
7
+ when /^Load error - (.+)/
8
+ @eturem_message_ja = %<ファイル "#{$1}" の読み込みに失敗しました。ファイル名を確認してください。>
9
+ end
10
+ super
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,19 @@
1
+ # coding: utf-8
2
+
3
+ module Eturem
4
+ module Errno_ENOENTExt
5
+ include ExceptionExt
6
+
7
+ def eturem_message()
8
+ @eturem_message_ja = "ファイルアクセスに失敗しました。"
9
+ if @eturem_message.match(/-\s*(?<filename>.+)\s*$/)
10
+ filename = Regexp.last_match(:filename).encode("utf-8")
11
+ @eturem_message_ja += %<ファイル "#{filename}" がありません。>
12
+ else
13
+ @eturem_message_ja += "ファイルがありません。"
14
+ end
15
+ @eturem_message_ja += "ファイル名を確認してください。"
16
+ super
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,12 @@
1
+ # coding: utf-8
2
+
3
+ module Eturem
4
+ module InterruptExt
5
+ include ExceptionExt
6
+
7
+ def eturem_message()
8
+ @eturem_message_ja = "プログラムが途中で強制終了されました。"
9
+ super
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ # coding: utf-8
2
+
3
+ module Eturem
4
+ module LoadErrorExt
5
+ include ExceptionExt
6
+
7
+ def eturem_message()
8
+ @eturem_message_ja =
9
+ %<ファイル/ライブラリ "#{self.path.encode("utf-8")}" が見つかりません。> +
10
+ %<ファイル/ライブラリ名を確認してください。>
11
+ super
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,222 @@
1
+ # coding: utf-8
2
+
3
+ require "eturem/base"
4
+ Dir[File.expand_path("..", __FILE__) + "/*.rb"].each do |path|
5
+ require path unless path == File.expand_path(__FILE__)
6
+ end
7
+
8
+ module Eturem
9
+ def self._extend_exception(exception)
10
+ ext = case exception
11
+ when NoMemoryError then NoMemoryErrorExt
12
+ when LoadError then LoadErrorExt
13
+ # when NotImplementedError then NotImplementedErrorExt
14
+ when SyntaxError then SyntaxErrorExt
15
+ # when ScriptError then ScriptErrorExt
16
+ # when SecurityError then SecurityErrorExt
17
+ when Interrupt then InterruptExt
18
+ # when SignalException then SignalExceptionExt
19
+ when UncaughtThrowError then UncaughtThrowErrorExt
20
+ when ArgumentError then ArgumentErrorExt
21
+ # when Encoding::CompatibilityError then Encoding_CompatibilityErrorExt
22
+ # when Encoding::ConverterNotFoundError then Encoding_ConverterNotFoundErrorExt
23
+ # when Encoding::InvalidByteSequenceError then Encoding_InvalidByteSequenceErrorExt
24
+ # when Encoding::UndefinedConversionError then Encoding_UndefinedConversionErrorExt
25
+ # when EncodingError then EncodingErrorExt
26
+ # when FiberError then FiberErrorExt
27
+ # when EOFError then EOFErrorExt
28
+ # when IOError then IOErrorExt
29
+ # when KeyError then KeyErrorExt
30
+ # when ClosedQueueError then ClosedQueueErrorExt
31
+ # when StopIteration then StopIterationExt
32
+ # when IndexError then IndexErrorExt
33
+ # when LocalJumpError then LocalJumpErrorExt
34
+ # when Math::DomainError then Math_DomainErrorExt
35
+ # when NoMethodError then NoMethodErrorExt
36
+ when NameError then NameErrorExt
37
+ # when FloatDomainError then FloatDomainErrorExt
38
+ # when RangeError then RangeErrorExt
39
+ # when RegexpError then RegexpErrorExt
40
+ # when RuntimeError then RuntimeErrorExt
41
+ # when Errno::E2BIG then Errno_E2BIGExt
42
+ # when Errno::EACCES then Errno_EACCESExt
43
+ # when Errno::EADDRINUSE then Errno_EADDRINUSEExt
44
+ # when Errno::EADDRNOTAVAIL then Errno_EADDRNOTAVAILExt
45
+ # when Errno::EADV then Errno_EADVExt
46
+ # when Errno::EAFNOSUPPORT then Errno_EAFNOSUPPORTExt
47
+ # when Errno::EAGAIN then Errno_EAGAINExt
48
+ # when Errno::EALREADY then Errno_EALREADYExt
49
+ # when Errno::EAUTH then Errno_EAUTHExt
50
+ # when Errno::EBADE then Errno_EBADEExt
51
+ # when Errno::EBADF then Errno_EBADFExt
52
+ # when Errno::EBADFD then Errno_EBADFDExt
53
+ # when Errno::EBADMSG then Errno_EBADMSGExt
54
+ # when Errno::EBADR then Errno_EBADRExt
55
+ # when Errno::EBADRPC then Errno_EBADRPCExt
56
+ # when Errno::EBADRQC then Errno_EBADRQCExt
57
+ # when Errno::EBADSLT then Errno_EBADSLTExt
58
+ # when Errno::EBFONT then Errno_EBFONTExt
59
+ # when Errno::EBUSY then Errno_EBUSYExt
60
+ # when Errno::ECANCELED then Errno_ECANCELEDExt
61
+ # when Errno::ECAPMODE then Errno_ECAPMODEExt
62
+ # when Errno::ECHILD then Errno_ECHILDExt
63
+ # when Errno::ECHRNG then Errno_ECHRNGExt
64
+ # when Errno::ECOMM then Errno_ECOMMExt
65
+ # when Errno::ECONNABORTED then Errno_ECONNABORTEDExt
66
+ # when Errno::ECONNREFUSED then Errno_ECONNREFUSEDExt
67
+ # when Errno::ECONNRESET then Errno_ECONNRESETExt
68
+ # when Errno::EDEADLK then Errno_EDEADLKExt
69
+ # when Errno::EDEADLOCK then Errno_EDEADLOCKExt
70
+ # when Errno::EDESTADDRREQ then Errno_EDESTADDRREQExt
71
+ # when Errno::EDOM then Errno_EDOMExt
72
+ # when Errno::EDOOFUS then Errno_EDOOFUSExt
73
+ # when Errno::EDOTDOT then Errno_EDOTDOTExt
74
+ # when Errno::EDQUOT then Errno_EDQUOTExt
75
+ # when Errno::EEXIST then Errno_EEXISTExt
76
+ # when Errno::EFAULT then Errno_EFAULTExt
77
+ # when Errno::EFBIG then Errno_EFBIGExt
78
+ # when Errno::EFTYPE then Errno_EFTYPEExt
79
+ # when Errno::EHOSTDOWN then Errno_EHOSTDOWNExt
80
+ # when Errno::EHOSTUNREACH then Errno_EHOSTUNREACHExt
81
+ # when Errno::EHWPOISON then Errno_EHWPOISONExt
82
+ # when Errno::EIDRM then Errno_EIDRMExt
83
+ # when Errno::EILSEQ then Errno_EILSEQExt
84
+ # when Errno::EINPROGRESS then Errno_EINPROGRESSExt
85
+ # when Errno::EINTR then Errno_EINTRExt
86
+ # when Errno::EINVAL then Errno_EINVALExt
87
+ # when Errno::EIO then Errno_EIOExt
88
+ # when Errno::EIPSEC then Errno_EIPSECExt
89
+ # when Errno::EISCONN then Errno_EISCONNExt
90
+ # when Errno::EISDIR then Errno_EISDIRExt
91
+ # when Errno::EISNAM then Errno_EISNAMExt
92
+ # when Errno::EKEYEXPIRED then Errno_EKEYEXPIREDExt
93
+ # when Errno::EKEYREJECTED then Errno_EKEYREJECTEDExt
94
+ # when Errno::EKEYREVOKED then Errno_EKEYREVOKEDExt
95
+ # when Errno::EL2HLT then Errno_EL2HLTExt
96
+ # when Errno::EL2NSYNC then Errno_EL2NSYNCExt
97
+ # when Errno::EL3HLT then Errno_EL3HLTExt
98
+ # when Errno::EL3RST then Errno_EL3RSTExt
99
+ # when Errno::ELIBACC then Errno_ELIBACCExt
100
+ # when Errno::ELIBBAD then Errno_ELIBBADExt
101
+ # when Errno::ELIBEXEC then Errno_ELIBEXECExt
102
+ # when Errno::ELIBMAX then Errno_ELIBMAXExt
103
+ # when Errno::ELIBSCN then Errno_ELIBSCNExt
104
+ # when Errno::ELNRNG then Errno_ELNRNGExt
105
+ # when Errno::ELOOP then Errno_ELOOPExt
106
+ # when Errno::EMEDIUMTYPE then Errno_EMEDIUMTYPEExt
107
+ # when Errno::EMFILE then Errno_EMFILEExt
108
+ # when Errno::EMLINK then Errno_EMLINKExt
109
+ # when Errno::EMSGSIZE then Errno_EMSGSIZEExt
110
+ # when Errno::EMULTIHOP then Errno_EMULTIHOPExt
111
+ # when Errno::ENAMETOOLONG then Errno_ENAMETOOLONGExt
112
+ # when Errno::ENAVAIL then Errno_ENAVAILExt
113
+ # when Errno::ENEEDAUTH then Errno_ENEEDAUTHExt
114
+ # when Errno::ENETDOWN then Errno_ENETDOWNExt
115
+ # when Errno::ENETRESET then Errno_ENETRESETExt
116
+ # when Errno::ENETUNREACH then Errno_ENETUNREACHExt
117
+ # when Errno::ENFILE then Errno_ENFILEExt
118
+ # when Errno::ENOANO then Errno_ENOANOExt
119
+ # when Errno::ENOATTR then Errno_ENOATTRExt
120
+ # when Errno::ENOBUFS then Errno_ENOBUFSExt
121
+ # when Errno::ENOCSI then Errno_ENOCSIExt
122
+ # when Errno::ENODATA then Errno_ENODATAExt
123
+ # when Errno::ENODEV then Errno_ENODEVExt
124
+ when Errno::ENOENT then Errno_ENOENTExt
125
+ # when Errno::ENOEXEC then Errno_ENOEXECExt
126
+ # when Errno::ENOKEY then Errno_ENOKEYExt
127
+ # when Errno::ENOLCK then Errno_ENOLCKExt
128
+ # when Errno::ENOLINK then Errno_ENOLINKExt
129
+ # when Errno::ENOMEDIUM then Errno_ENOMEDIUMExt
130
+ # when Errno::ENOMEM then Errno_ENOMEMExt
131
+ # when Errno::ENOMSG then Errno_ENOMSGExt
132
+ # when Errno::ENONET then Errno_ENONETExt
133
+ # when Errno::ENOPKG then Errno_ENOPKGExt
134
+ # when Errno::ENOPROTOOPT then Errno_ENOPROTOOPTExt
135
+ # when Errno::ENOSPC then Errno_ENOSPCExt
136
+ # when Errno::ENOSR then Errno_ENOSRExt
137
+ # when Errno::ENOSTR then Errno_ENOSTRExt
138
+ # when Errno::ENOSYS then Errno_ENOSYSExt
139
+ # when Errno::ENOTBLK then Errno_ENOTBLKExt
140
+ # when Errno::ENOTCAPABLE then Errno_ENOTCAPABLEExt
141
+ # when Errno::ENOTCONN then Errno_ENOTCONNExt
142
+ # when Errno::ENOTDIR then Errno_ENOTDIRExt
143
+ # when Errno::ENOTEMPTY then Errno_ENOTEMPTYExt
144
+ # when Errno::ENOTNAM then Errno_ENOTNAMExt
145
+ # when Errno::ENOTRECOVERABLE then Errno_ENOTRECOVERABLEExt
146
+ # when Errno::ENOTSOCK then Errno_ENOTSOCKExt
147
+ # when Errno::ENOTSUP then Errno_ENOTSUPExt
148
+ # when Errno::ENOTTY then Errno_ENOTTYExt
149
+ # when Errno::ENOTUNIQ then Errno_ENOTUNIQExt
150
+ # when Errno::ENXIO then Errno_ENXIOExt
151
+ # when Errno::EOPNOTSUPP then Errno_EOPNOTSUPPExt
152
+ # when Errno::EOVERFLOW then Errno_EOVERFLOWExt
153
+ # when Errno::EOWNERDEAD then Errno_EOWNERDEADExt
154
+ # when Errno::EPERM then Errno_EPERMExt
155
+ # when Errno::EPFNOSUPPORT then Errno_EPFNOSUPPORTExt
156
+ # when Errno::EPIPE then Errno_EPIPEExt
157
+ # when Errno::EPROCLIM then Errno_EPROCLIMExt
158
+ # when Errno::EPROCUNAVAIL then Errno_EPROCUNAVAILExt
159
+ # when Errno::EPROGMISMATCH then Errno_EPROGMISMATCHExt
160
+ # when Errno::EPROGUNAVAIL then Errno_EPROGUNAVAILExt
161
+ # when Errno::EPROTO then Errno_EPROTOExt
162
+ # when Errno::EPROTONOSUPPORT then Errno_EPROTONOSUPPORTExt
163
+ # when Errno::EPROTOTYPE then Errno_EPROTOTYPEExt
164
+ # when Errno::ERANGE then Errno_ERANGEExt
165
+ # when Errno::EREMCHG then Errno_EREMCHGExt
166
+ # when Errno::EREMOTE then Errno_EREMOTEExt
167
+ # when Errno::EREMOTEIO then Errno_EREMOTEIOExt
168
+ # when Errno::ERESTART then Errno_ERESTARTExt
169
+ # when Errno::ERFKILL then Errno_ERFKILLExt
170
+ # when Errno::EROFS then Errno_EROFSExt
171
+ # when Errno::ERPCMISMATCH then Errno_ERPCMISMATCHExt
172
+ # when Errno::ESHUTDOWN then Errno_ESHUTDOWNExt
173
+ # when Errno::ESOCKTNOSUPPORT then Errno_ESOCKTNOSUPPORTExt
174
+ # when Errno::ESPIPE then Errno_ESPIPEExt
175
+ # when Errno::ESRCH then Errno_ESRCHExt
176
+ # when Errno::ESRMNT then Errno_ESRMNTExt
177
+ # when Errno::ESTALE then Errno_ESTALEExt
178
+ # when Errno::ESTRPIPE then Errno_ESTRPIPEExt
179
+ # when Errno::ETIME then Errno_ETIMEExt
180
+ # when Errno::ETIMEDOUT then Errno_ETIMEDOUTExt
181
+ # when Errno::ETOOMANYREFS then Errno_ETOOMANYREFSExt
182
+ # when Errno::ETXTBSY then Errno_ETXTBSYExt
183
+ # when Errno::EUCLEAN then Errno_EUCLEANExt
184
+ # when Errno::EUNATCH then Errno_EUNATCHExt
185
+ # when Errno::EUSERS then Errno_EUSERSExt
186
+ # when Errno::EWOULDBLOCK then Errno_EWOULDBLOCKExt
187
+ # when Errno::EXDEV then Errno_EXDEVExt
188
+ # when Errno::EXFULL then Errno_EXFULLExt
189
+ # when Errno::EXXX then Errno_EXXXExt
190
+ # when Errno::NOERROR then Errno_NOERRORExt
191
+ # when SystemCallError then SystemCallErrorExt
192
+ # when ThreadError then ThreadErrorExt
193
+ when TypeError then TypeErrorExt
194
+ when ZeroDivisionError then ZeroDivisionErrorExt
195
+ # when StandardError then StandardErrorExt
196
+ when SystemStackError then SystemStackErrorExt
197
+ end
198
+ return ext if ext
199
+ ext = case exception.class.to_s
200
+ # when "FrozenError" then FrozenErrorExt
201
+ when "DXRuby::DXRubyError" then DXRubyErrorExt
202
+ end
203
+ return ext
204
+ end
205
+
206
+ module ExceptionExt
207
+ def eturem_location_to_s(location)
208
+ %<"#{location.path}" #{location.lineno}行目: '#{location.label}'>
209
+ end
210
+
211
+ def eturem_traceback(order = :bottom)
212
+ order == :top ? "" : "\e[1mTraceback\e[0m(エラー発生までの流れを直前のものほど下に表示しています。):\n"
213
+ end
214
+
215
+ def eturem_message()
216
+ "\e[1;31m【エラー】\e[0m" +
217
+ (@eturem_path == "(eval)" ? "eval 中の" : %<ファイル"#{@eturem_path}">) +
218
+ " #{@eturem_lineno}行目:\e[1m(\e[4m#{self.class}\e[0;1m)\n" +
219
+ "#{@eturem_message_ja || @eturem_message}"
220
+ end
221
+ end
222
+ end
@@ -0,0 +1,50 @@
1
+ module Eturem
2
+ module NameErrorExt
3
+ include ExceptionExt
4
+
5
+ def eturem_message()
6
+ if self.name.to_s.encode("utf-8").include?(" ")
7
+ eturem_multibyte_space
8
+ elsif self.name.to_s.encode("utf-8").match(/[”’`(){}#]/)
9
+ eturem_multibyte_char
10
+ elsif self.receiver == nil
11
+ eturem_receiver_is_nil
12
+ else
13
+ eturem_basic_name_error
14
+ end
15
+ super
16
+ end
17
+
18
+ def eturem_multibyte_space
19
+ @eturem_script_lines = Eturem::Base.read_script(@eturem_path)
20
+ Eturem::Base.highlight(@eturem_script_lines[@eturem_lineno], / +/, "\e[1;4;31m")
21
+ @eturem_message_ja = "スクリプト中に全角空白が混じっています。"
22
+ end
23
+
24
+ def eturem_multibyte_char
25
+ @eturem_script_lines = Eturem::Base.read_script(@eturem_path)
26
+ if @eturem_script_lines[@eturem_lineno]
27
+ @eturem_script_lines[@eturem_lineno].gsub!(/[”’`()#]+/){ "\e[1;4;31m#{$&}\e[0m" }
28
+ end
29
+ @eturem_message_ja = "スクリプト中に全角記号が混じっています。"
30
+ end
31
+
32
+ def eturem_receiver_is_nil
33
+ @eturem_message_ja =
34
+ "nil に対して #{self.name.to_s.encode("utf-8")} というメソッドを呼び出そうとしています。\n" +
35
+ "変数の値/メソッドの返値が予期せず nil になっている可能性があります。"
36
+ end
37
+
38
+ def eturem_basic_name_error
39
+ @eturem_message_ja =
40
+ (self.is_a?(NoMethodError) ? "メソッド" : "変数/メソッド") +
41
+ "「\e[1;4;31m#{self.name.to_s.encode("utf-8")}\e[0m」は存在しません。"
42
+ unless @eturem_corrections.empty?
43
+ did_you_mean = @eturem_corrections.map{ |d|
44
+ "\e[1;33m#{d.to_s.encode("utf-8")}\e[0m"
45
+ }.join(" / ")
46
+ @eturem_message_ja += "「#{did_you_mean}」の入力ミスではありませんか?"
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,12 @@
1
+ # coding: utf-8
2
+
3
+ module Eturem
4
+ module NoMemoryErrorExt
5
+ include ExceptionExt
6
+
7
+ def eturem_message()
8
+ @eturem_message_ja = "メモリを確保できませんでした。あまりにも大量のデータを作成していませんか?"
9
+ super
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,88 @@
1
+ module Eturem
2
+ module SyntaxErrorExt
3
+ include ExceptionExt
4
+
5
+ def eturem_message()
6
+ if @eturem_message.match(/unexpected (?<unexpected>(?:','|[^,])+)/)
7
+ eturem_unexpected(eturem_transform_keyword(Regexp.last_match(:unexpected)))
8
+ elsif @eturem_message.match(/Invalid (?<invalid>(?:break|next|retry|redo|yield))/)
9
+ eturem_invalid(Regexp.last_match(:invalid))
10
+ elsif @eturem_message.include?("unterminated string meets end of file")
11
+ eturem_unterminated_string
12
+ elsif @eturem_message.include?("unterminated regexp meets end of file")
13
+ eturem_unterminated_regexp
14
+ end
15
+ super
16
+ end
17
+
18
+ def eturem_unexpected(unexpected)
19
+ expecting = ["ファイルの末尾"]
20
+ if @eturem_message.match(/[,\s]expecting (?<expecting>.+)/)
21
+ expecting = Regexp.last_match(:expecting).split(" or ").map do |exp|
22
+ eturem_transform_keyword(exp)
23
+ end
24
+ end
25
+ Eturem::Base.highlight(@eturem_script_lines[@eturem_lineno], unexpected, "\e[1;4;31m")
26
+
27
+ keywords = %w[if unless case while until for begin def class module do].select do |keyword|
28
+ @eturem_script_lines.join.include?(keyword)
29
+ end
30
+ keywords = "「#{keywords.join(" / ")}」"
31
+ keywords = "ifなど" if keywords == "「」"
32
+ if unexpected == "ファイルの末尾"
33
+ @eturem_message_ja =
34
+ "(ただし、実際のエラーの原因はおそらく#{@eturem_lineno}行目より前にあります。)\n"
35
+ if expecting.join == "ファイルの末尾"
36
+ @eturem_message_ja += "構文エラーです。何か足りないものがあるようです。"
37
+ else
38
+ @eturem_message_ja += "構文エラーです。 #{expecting.join(" または ")} が足りない可能性があります。"
39
+ end
40
+ if expecting.include?("end")
41
+ @eturem_message_ja += "#{keywords}に対応する「end」があるか確認してください。"
42
+ end
43
+ elsif expecting.join == "ファイルの末尾"
44
+ @eturem_message_ja =
45
+ "構文エラーです。予期せぬ #{unexpected} があります。以下のような可能性があります。\n" +
46
+ "・その直前に何らかのエラーの原因がある。\n" +
47
+ "・#{unexpected} が余分に書かれている、またはタイプミスで予期せず書いてしまった。"
48
+ if unexpected == "end"
49
+ @eturem_message_ja += "\n・#{keywords}と「end」の対応が合っていない。"
50
+ end
51
+ elsif !expecting.empty?
52
+ @eturem_message_ja =
53
+ "構文エラーです。 #{expecting.join(" または ")} が来るべき場所に、" +
54
+ "#{unexpected} が来てしまいました。"
55
+ end
56
+ end
57
+
58
+ def eturem_invalid(invalid)
59
+ Eturem::Base.highlight(@eturem_script_lines[@eturem_lineno], invalid, "\e[1;4;31m")
60
+ @eturem_message_ja = "#{invalid} が不適切な場所にあります。"
61
+ end
62
+
63
+ def eturem_unterminated_string()
64
+ @eturem_message_ja = "文字列が閉じられていません。「\"」や「'」を確認してください。"
65
+ end
66
+
67
+ def eturem_unterminated_regexp()
68
+ @eturem_message_ja = "正規表現が閉じられていません。「/」を確認してください。"
69
+ end
70
+
71
+ def eturem_transform_keyword(keyword)
72
+ case keyword
73
+ when "end-of-input", "$end"
74
+ "ファイルの末尾"
75
+ when /^(?:keyword|modifier)_/
76
+ Regexp.last_match.post_match
77
+ when "'\\n'"
78
+ "改行"
79
+ when "backslash"
80
+ "\\"
81
+ when /^[`']([^']+)'$/
82
+ $1
83
+ else
84
+ keyword
85
+ end
86
+ end
87
+ end
88
+ end