Sha256: 5cf1b492cbff94e8d4de59a302876a287033e18600600c8de5f5dbb0af2cba58
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
# encoding: utf-8 # frozen_string_literal: true module Carbon module Compiler class Parser module Statements # Parses an if statement. module If protected def parse_statement_if expect :if expect :"(" condition = parse_expression expect :")" body = parse_statement follow = parse_statement_if_continued Node::Statement::If.new([condition, body, follow]) end def parse_statement_if_continued case peek.type when :elsif then parse_statement_if_elsif when :else then parse_statement_if_else end end def parse_statement_if_elsif expect :elsif expect :"(" condition = parse_expression expect :")" body = parse_statement follow = parse_statement_if_continued Node::Statement::Elsif.new([condition, body, follow]) end def parse_statement_if_else expect :else Node::Statement::Else.new([parse_statement]) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
carbon-compiler-0.2.0 | lib/carbon/compiler/parser/statements/if.rb |