Class: Kwartz::RubyStyleParser

Inherits:
PresentationLogicParser show all
Defined in:
lib/kwartz/parser.rb

Overview

ruby style presentation logic parser

presentation logic example (ruby style):

# comment
element "list" {
  value  @var
  attrs  "class"=>@clssname, "bgcolor"=>color
  append @value==item['list'] ? ' checked' : ''
  logic {
    @list.each { |item|
      _stag
      _cont
      _etag
    }
  }
}

Constant Summary

Constants inherited from PresentationLogicParser

PresentationLogicParser::ESCAPE_FLAG_TABLE, PresentationLogicParser::PLOGIC_KEYWORDS

Instance Attribute Summary

Attributes inherited from PresentationLogicParser

#column, #error, #linenum, #pos, #token, #value

Instance Method Summary collapse

Methods inherited from PresentationLogicParser

#escape?, get_class, #getch, #initialize, #parse_error, register_class, #scan, #scan_block, #scan_ident, #scan_line, #scan_string, #scan_string_dquoted, #scan_string_quoted

Methods included from Assertion

assert

Methods included from CharacterType

#is_alpha, #is_digit, #is_identchar, #is_whitespace

Constructor Details

This class inherits a constructor from Kwartz::PresentationLogicParser

Instance Method Details

#parse(input, filename = '') ⇒ Object



407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
# File 'lib/kwartz/parser.rb', line 407

def parse(input, filename='')
  reset(input, filename)
  scan()
  nodes = []
  while @token != nil
    if @token == :element
      node = parse_element_ruleset()
    elsif @token == :document
      node = parse_document_ruleset()
    else
      raise parse_error("'#{@value}': element or document required.")
    end
    nodes << node
  end
  return nodes
end