Permalink
Browse files

Add a little more doc on what next() and expandable handlers are

  • Loading branch information...
Floby committed Jun 20, 2011
1 parent de65526 commit e019efcc94fecf59650ba6c8d1999df48202ac94
Showing with 9 additions and 0 deletions.
  1. +9 −0 README.markdown
View
@@ -58,9 +58,18 @@ Handlers are just javascript functions accepting the following arguments:
* `type` the type of this token (i.e. `'number'`, `'whitespace'`, `'word'`)
* `next` a function to specify what needs to be called on the next token(s)
+the `next` function takes a random number of handlers which will be pushed
+in front of the handlers queue (they will be _next_!).
returning `true` from a handler causes the same token to be reemitted
to the next handler.
+This allows you to define handlers doing some kind of "sniffing" if you find
+yourself in a state in which you cannot determine what will come next.
+This kind of handlers _expand_ themselves to a greater number of handlers that
+will effectively parse the following tokens. They do that by adding a few handlers
+to the queue with `next` and returning `true` to notify the parser that the token
+should be reemitted.
+
### Handlers utilities
there are a few handlers factories provided by this module.

0 comments on commit e019efc

Please sign in to comment.