Class: RLSL::Prism::SourceUnitParser
- Inherits:
-
Object
- Object
- RLSL::Prism::SourceUnitParser
- Defined in:
- lib/rlsl/prism/source_unit/parser.rb
Instance Method Summary collapse
-
#initialize(source) ⇒ SourceUnitParser
constructor
A new instance of SourceUnitParser.
- #parse ⇒ Object
Constructor Details
#initialize(source) ⇒ SourceUnitParser
Returns a new instance of SourceUnitParser.
8 9 10 |
# File 'lib/rlsl/prism/source_unit/parser.rb', line 8 def initialize(source) @source = source.to_s end |
Instance Method Details
#parse ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rlsl/prism/source_unit/parser.rb', line 12 def parse normalized = @source.strip return SourceUnit.new(params: [], body: "") if normalized.empty? params_source, body_source = split_sections(normalized) validate_body!(body_source) SourceUnit.new( params: parse_params(params_source), body: body_source.strip ) end |