ooparser.rb

Path: lib/ooparser.rb  (CVS)
Last Update: Thu Sep 08 01:41:20 MDT 2005

OOParser - an object-oriented parser superclass

Synopsis

  class MyParser < OOParser

      def initialize
          @syntree = []
      end

      grammar {
          rule document, "<title>? <paragraph>+ <bibliography>?" do |match|
              doc = Document::new
              doc.title = match.title
              doc.paragraphs = match.paragraph
              doc.bibliography = match.biliography
              return doc
          end

          rule title, "= <word>+ ...<eol>" do |match|
              return match.word.join(' ')
          end

          rule paragraph, "<blankline>+ <line>+ ...<eol>" do |match|
              return match.line.join
          end

          rule bibliography, "..." do |match|
              ...
          end

          rule line, /^.*$/
          rule word, /\w+/
          rule blankline, "<eol><eol>"
          rule eol, "<skip: ''>\n"
      }

  end

Authors

  • Michael Granger <ged@FaerieMUD.org>

Copyright

Copyright © 2003-2005 The FaerieMUD Consortium. All rights reserved.

This module is free software. You may use, modify, and/or redistribute this software under the same terms as Ruby itself (see www.ruby-lang.org/en/LICENSE.txt).

Version

 $Id: ooparser.rb 5 2005-09-08 07:41:12Z ged $

Required files

strscan   logger   e2mmap   ooparser/grammar   ooparser/rule   ooparser/production   ooparser/item   ooparser/parsestate   linguistics  

[Validate]