Sha256: 6012ce3dc8755a9bed14b4f7e9c1058292ef9d91592b9db53da12674ea41853a

Contents?: true

Size: 1.86 KB

Versions: 2

Compression:

Stored size: 1.86 KB

Contents

class Tailor

  # These are important tokens that key certain styling events.  They are taken
  # from:
  # https://github.com/ruby/ruby/blob/trunk/ext/ripper/eventids2.c
  # https://github.com/ruby/ruby/blob/trunk/parse.y
  module LexerConstants
    KEYWORDS_TO_INDENT = [
      'begin',
      'case',
      'class',
      'def',
      'do',
      'else',
      'elsif',
      'ensure',
      'for',
      'if',
      'module',
      'rescue',
      'unless',
      'until',
      'when',
      'while'
    ]

    CONTINUATION_KEYWORDS = [
      'elsif',
      'else',
      'ensure',
      'rescue',
      'when'
    ]

    KEYWORDS_AND_MODIFIERS = [
      'if',
      'unless',
      'until',
      'while'
    ]

    MODIFIERS = {
      'if' => :if_mod,
      'rescue' => :rescue_mod,
      'unless' => :unless_mod,
      'until' => :until_mod,
      'while' => :while_mod
    }

    MULTILINE_OPERATORS = [
      '+', '-', '*', '**', '/', '%',    # +, -, tSTAR, tPOW, /, %
      '<', '>', '<=', '>=',             # <, >, tLEQ, tGEQ
      '=', '+=', '-=', '*=', '**=', '/=', '%=',
      '&&=', '||=', '<<=',              # ...tOP_ASGN...
      '>>', '<<',                       # tRSHFT, tLSHFT
      '!', '&', '?', ':', '^', '~',     # !, tAMPER, ?, :, ^, ~
      #'|',
      '&&', '||',                       # tANDOP, tOROP
      '==', '===', '<=>', '!=',         # tEQ, tEQQ, tCMP, tNEQ
      '=~', '!~',                       # tMATCH, tNMATCH
      '..', '...',                      # tDOT2, tDOT3
      '::',                             # tCOLON2 (not sure about tCOLON3)
      #'[]', '[]=',                      # tAREF, tASET (not sure about these)
      '=>',                             # tASSOC
      '->',                             # tLAMBDA
      '~>'                              # gem_version op
    ]

    LOOP_KEYWORDS = [
      'for',
      'until',
      'while'
    ]
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tailor-1.0.0.alpha2 lib/tailor/lexer_constants.rb
tailor-1.0.0.alpha lib/tailor/lexer_constants.rb