Class: MilkTea::Token
- Inherits:
-
Object
- Object
- MilkTea::Token
- Defined in:
- lib/milk_tea/core/token.rb
Constant Summary collapse
- KEYWORDS =
MilkTea::KEYWORDS
- ASSIGNMENT_TYPES =
%i[ equal plus_equal minus_equal star_equal slash_equal percent_equal amp_equal pipe_equal caret_equal shift_left_equal shift_right_equal ].freeze
- LINE_START_OPERATOR_TYPES =
Operator token types that may never begin a statement. A statement that spans multiple lines must end the previous line with one of LINE_CONTINUATION_OPERATORS or wrap the expression in ( ) — it must never start the next line with an operator.
%i[ dot_dot plus minus star slash percent pipe amp caret tilde or and is equal_equal bang_equal less less_equal greater greater_equal shift_left shift_right ].freeze
- LINE_CONTINUATION_OPERATORS =
Binary operators that continue a statement when they end a physical line. Unary-only
~is excluded because it has no left operand. (LINE_START_OPERATOR_TYPES - [:tilde]).freeze
Instance Method Summary collapse
Instance Method Details
#assignment? ⇒ Boolean
31 32 33 |
# File 'lib/milk_tea/core/token.rb', line 31 def assignment? ASSIGNMENT_TYPES.include?(type) end |
#eof? ⇒ Boolean
35 36 37 |
# File 'lib/milk_tea/core/token.rb', line 35 def eof? type == :eof end |
#with_appended_trailing_trivia(trivia) ⇒ Object
39 40 41 |
# File 'lib/milk_tea/core/token.rb', line 39 def with_appended_trailing_trivia(trivia) with(trailing_trivia: trailing_trivia + [trivia]) end |