Module: Ibex::Frontend::TokenAdapter::DeclarationLexerState
- Included in:
- DeclarationState
- Defined in:
- lib/ibex/frontend/token_adapter/declaration_lexer_state.rb,
sig/ibex/frontend/token_adapter/declaration_lexer_state.rbs
Overview
Context transitions for the extended root-only lexer declaration.
Instance Method Summary collapse
- #begin_lexer_entry(token) ⇒ external_token
- #classify_lexer_identifier(token) ⇒ external_token
- #classify_lexer_scalar(type) ⇒ external_token?
- #finish_lexer_scope ⇒ external_token
- #lexer_declaration_state? ⇒ Boolean
Instance Method Details
#begin_lexer_entry(token) ⇒ external_token
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ibex/frontend/token_adapter/declaration_lexer_state.rb', line 36 def begin_lexer_entry(token) # @type self: DeclarationState value = string_value(token) case value when "end" then finish_lexer_scope when "state" @state = :lexer_state_name :STATE when "skip" @state = :lexer_pattern :SKIP when "on" @state = :lexer_pattern :ON else @state = :lexer_pattern :IDENTIFIER end end |
#classify_lexer_identifier(token) ⇒ external_token
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ibex/frontend/token_adapter/declaration_lexer_state.rb', line 16 def classify_lexer_identifier(token) # @type self: DeclarationState case @state when :lexer_entries, :lexer_action_or_entry then begin_lexer_entry(token) when :lexer_state_name @state = :lexer_state_do :IDENTIFIER when :lexer_state_do value = string_value(token) raise Ibex::Error, "#{token.location}: expected do, got #{value}" unless value == "do" @lexer_state_depth = (@lexer_state_depth || 0) + 1 @state = :lexer_entries :DO else :IDENTIFIER end end |
#classify_lexer_scalar(type) ⇒ external_token?
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/ibex/frontend/token_adapter/declaration_lexer_state.rb', line 70 def classify_lexer_scalar(type) if @state == :lexer_pattern && %i[REGEXP LITERAL].include?(type) @state = :lexer_action_or_entry return type end return unless @state == :lexer_action_or_entry && type == :ACTION @state = :lexer_entries type end |
#finish_lexer_scope ⇒ external_token
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/ibex/frontend/token_adapter/declaration_lexer_state.rb', line 57 def finish_lexer_scope depth = @lexer_state_depth || 0 if depth.positive? @lexer_state_depth = depth - 1 @state = :lexer_entries else @state = :declaration @declaration = nil end :END end |
#lexer_declaration_state? ⇒ Boolean
11 12 13 |
# File 'lib/ibex/frontend/token_adapter/declaration_lexer_state.rb', line 11 def lexer_declaration_state? @declaration == :lexer end |