Skip to content

jnpn/grammarize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

94 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grammarize

Turns a tree into grammar rules.

Simply walks the tree and gather descendancy relationships, then grouped by parent to form a descriptive grammar. (pompous)

Requirements

  • click
  • sax [wip]

Usage

generate a tree

gen-tree uses a html tag subset and a default depth of 4.

python main.py gen-tree

show bnf

show-bnf generates a tree (see above) and then computes its BNF.

python main.py show-bnf
  • Gree a
  • Gree pre
  • Gree div
  • Gree span
  • Gree h3
  • Gree audio
  • Gree video
  • Gree pre
  • Gree h1
  • Gree h2
  • Gree h3
  • Gree audio
  • Gree a
  • Gree pre
  • Gree h1

<a> ::= <h1> | <pre> <audio> ::= <video> | <pre> <div> ::= <h3> | <span> <h1> ::= <h2> | <a> <h2> ::= <audio> | <h3> <pre> ::= <audio> | <div>

OpenDocument Example

@>>> print(opendocument.bnf())
<office:font-face-decls> ::= <style:font-face>
<style:table-row-properties> ::=
<office:text> ::= <text:p> | <text:sequence-decls> | <table:table> | <office:forms>
<style:paragraph-properties> ::=
<style:table-properties> ::=
<office:document-content> ::= <office:scripts/> | <office:body> | <office:font-face-decls> \
                          | <office:automatic-styles>
<style:text-properties> ::=
<table:table-row> ::= <table:table-cell> | <table:covered-table-cell/>
<table:table> ::= <table:table-column> | <table:table-row>
<style:style> ::= <style:table-row-properties> | <style:table-properties> | <style:table-column-properties> \
              | <style:text-properties> | <style:table-cell-properties> | <style:paragraph-properties>
<office:scripts/> ::=
<text:sequence-decls> ::= <text:sequence-decl>
<office:forms> ::=
<Document> ::= <office:document-content>
<style:font-face> ::=
<style:table-column-properties> ::=
<style:table-cell-properties> ::=
<office:automatic-styles> ::= <style:style>
<table:table-cell> ::= <text:p>
<text:sequence-decl> ::=
<table:table-column> ::=
<text:span> ::= <text:span>
<office:body> ::= <office:text>
<table:covered-table-cell/> ::=
<text:p> ::= <text:span>

TODOS

fix rules_ rules__ logic

it’s probably full of unnecessary steps

WIP useful test suite

POS order for rules.

Releases

No releases published

Packages

No packages published

Languages