0.2.1 • Published 9 years ago

commonform-new-markup v0.2.1

Weekly downloads
3
License
Apache-2.0
Repository
github
Last release
9 years ago

Parse Common Form markup, returning an object containing a form and an array of path-to-blank mappings.

var parse = require('commonform-markup-parse')
parse(stringOfMarkup); // => { form: Object, directions: Array }

The parser is made of several components:

  1. a hand-coded context-tracking tokenizer (or lexer) that emits tokens for indentation and outdentation, in addition to content tokens
  2. an LALR(1) parser generated by Jison from a Bison-like BNF grammar
  3. commonform-fix-strings to convert the parser's AST to a valid common form by fixing various string-related validation issues, like extra space
  4. a tiny algorithm that removes the hints text from fill-in-the-blanks within the form, and emits path-to-hint mappings instead

The parser passes the commonform-markup-tests test suite.

If you'd like to write a parser in a different language, the test suite and this package are best places to start. Your language probably already has a Bison clone or a BNF-compatible parser combinators library.