Class: RubyLexer::NestedContexts::RescueSMContext
- Inherits:
-
ListContext
- Object
- NestedContext
- ListContext
- RubyLexer::NestedContexts::RescueSMContext
- Defined in:
- lib/rubylexer/context.rb
Constant Summary collapse
- EVENTS =
normal progression: rescue => arrow => then
[:rescue,:arrow,:then,:semi,:colon]
- LEGAL_SUCCESSORS =
{ nil=> [:rescue], :rescue => [:arrow,:then,:semi,:colon], :arrow => [:then,:semi,:colon], :then => [] }
Instance Attribute Summary collapse
-
#state ⇒ Object
readonly
note on :semi and :colon events: (unescaped) newline, semicolon, and (unaccompanied) colon also trigger the :then event.
Attributes inherited from NestedContext
Instance Method Summary collapse
-
#initialize(linenum) ⇒ RescueSMContext
constructor
A new instance of RescueSMContext.
- #see(lxr, msg) ⇒ Object
Methods inherited from NestedContext
#lhs, #lhs=, #matches?, #wantarrow
Constructor Details
#initialize(linenum) ⇒ RescueSMContext
Returns a new instance of RescueSMContext.
260 261 262 263 264 |
# File 'lib/rubylexer/context.rb', line 260 def initialize linenum dflt_initialize("rescue","then",linenum) @state=nil @state=:rescue end |
Instance Attribute Details
#state ⇒ Object (readonly)
note on :semi and :colon events:
(unescaped) newline, semicolon, and (unaccompanied) colon
also trigger the :then event. they are ignored if in :then
state already.
258 259 260 |
# File 'lib/rubylexer/context.rb', line 258 def state @state end |
Instance Method Details
#see(lxr, msg) ⇒ Object
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'lib/rubylexer/context.rb', line 266 def see(lxr,msg) stack=lxr.parsestack case msg when :rescue; WantsEndContext===stack.last or BlockContext===stack.last or ParenContext===stack.last or raise 'syntax error: rescue not expected at this time' when :arrow; #local var defined in this state when :then,:semi,:colon; msg=:then self.equal? stack.pop or raise 'syntax error: then not expected at this time' #pop self off owning context stack when :comma, :splat; return else super end LEGAL_SUCCESSORS[@state].include? msg or raise "rescue syntax error: #{msg} unexpected in #@state" @state=msg end |