net.aethersanctum.curlyml
Class Parser

java.lang.Object
  extended by net.aethersanctum.curlyml.Parser

public class Parser
extends java.lang.Object

The purpose of the Parser is to generate a stream of events to be handled by a ParseEventHandler. The Parser is dumb by design. It doesn't know about Documents. All it knows how to do is check syntax and create events for inteception by a ParseEventHandler (like, say a DocumentLoader, which knows how to create a Document from parse events).

Other kinds of ParseEventHandlers might just process a stream of events and produce another stream without any kind of intermediate in-memory Document model. (e.g. a translator to convert CurlyML into HTML).

Author:
ben

Constructor Summary
Parser(java.io.Reader r, ParseEventHandler handler)
          create a new parser to parse the input from Reader r and send parse events to the handler.
 
Method Summary
 java.lang.String join(java.util.List<java.lang.String> wordList)
          join a list of words into a single string, delimited by spaces.
protected  int parseBlock(int depth)
          parse a block in the document.
 void parseInput()
          Performs the entire parsing process.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Parser

public Parser(java.io.Reader r,
              ParseEventHandler handler)
create a new parser to parse the input from Reader r and send parse events to the handler. Call parseInput() after this.

Parameters:
r -
handler -
See Also:
parseInput()
Method Detail

parseInput

public void parseInput()
                throws java.io.IOException,
                       SyntaxException
Performs the entire parsing process.

Throws:
java.io.IOException
SyntaxException

join

public java.lang.String join(java.util.List<java.lang.String> wordList)
join a list of words into a single string, delimited by spaces.

Parameters:
wordList -
Returns:

parseBlock

protected int parseBlock(int depth)
                  throws java.io.IOException,
                         SyntaxException
parse a block in the document. if we run into a curly, assume a sub-block is starting. fire off parsing events. check syntax along the way.

Parameters:
depth -
Returns:
Throws:
java.io.IOException
SyntaxException