Sha256: 15618904de2a9485c0c42849e37c3edc79263b10df702b97cbf29c5ca1468d33
Contents?: true
Size: 1.47 KB
Versions: 10
Compression:
Stored size: 1.47 KB
Contents
class Code class Parser class Operation < ::Code::Parser def initialize(input, operators:, subclass:, **kargs) super(input, **kargs) @operators = operators @subclass = subclass end def parse previous_cursor = cursor left = parse_subclass(subclass) if left previous_cursor = cursor comments = parse_comments right = [] while operator = match(operators) comments_before = parse_comments statement = parse_subclass(subclass) comments_after = parse_comments if statement right << { statement: statement, operator: operator, comments_before: comments_before, comments_after: comments_after }.compact else @cursor = previous_cursor buffer! break end end if right.empty? @cursor = previous_cursor buffer! left else right[-1].delete(:comments_after) { operation: { left: left, right: right, comments: comments }.compact } end else @cursor = previous_cursor buffer! return end end private attr_reader :operators, :subclass end end end
Version data entries
10 entries across 10 versions & 2 rubygems