ebnf 0.3.8 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -1
  3. data/VERSION +1 -1
  4. data/lib/ebnf/writer.rb +10 -6
  5. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e20a4ebabd510b7007ee36dad90ee06fb36013d4
4
- data.tar.gz: 27892bda5632de5c9d6d94f87ddb24aacb755449
3
+ metadata.gz: b0a5b5d879cad3c68665f4cc360299ec06934f91
4
+ data.tar.gz: 3310fb9e5dc956f6d51cde5d6a4cc816ef78fc4e
5
5
  SHA512:
6
- metadata.gz: 61b86236fc3ba702e4ed672499b6449efc9727d46d5ebc3bf7874b4ea6162df9a697fdc6815f5279a0ddbb45c7476f5126403a483fa7bf49594b16019bb632ce
7
- data.tar.gz: 4181b655381f3a0e7dec3e57444f4793416ff1c3327757e2285e31252f3dfb3ae80f986dd9fb14a7ab7dc273712d71dbf49c6d9e37b63945590f9023fc03f4d1
6
+ metadata.gz: c4f1450e2035d5f0457b98a00d7e89b4a397f6899d16fa0bcfa78c4cb88d287eaff5e4ef5435c2a06612b3d972b544770300ce1608f743215cde3aee0b275385
7
+ data.tar.gz: a44d8ed56897dcb5eb224c7dba62d5876e50e979eb0d95459fa7cd2714626d4414f11d27b1661f3fefe755766362ba7048ee3bb4256b4bc888d3fe6703e7b44c
data/README.md CHANGED
@@ -36,6 +36,10 @@ Generate Terminal, [First/Follow and Branch][] tables as Ruby for parsing gramma
36
36
 
37
37
  ebnf.to_ruby
38
38
 
39
+ Generate formatted grammar using HTML (requires [Haml][Haml] gem)
40
+
41
+ ebnf.to_html
42
+
39
43
  ### Creating terminal definitions and parser rules to parse generated grammars
40
44
 
41
45
  The parser is initialized to callbacks invoked on entry and exit
@@ -80,6 +84,7 @@ to each `terminal` and `production`. A trivial parser loop can be described as f
80
84
  raise RDF::ReaderError, e.message if validate?
81
85
  end
82
86
 
87
+
83
88
  ## EBNF Grammar
84
89
  The [EBNF][] variant used here is based on [W3C](http://w3.org/) [EBNF][] (see {file:etc/ebnf.ebnf EBNF grammar}) as defined in the
85
90
  [XML 1.0 recommendation](http://www.w3.org/TR/REC-xml/), with minor extensions.
@@ -102,7 +107,6 @@ and [First Follow Notation-3 rules](http://www.w3.org/2000/10/swap/grammar/first
102
107
  Full documentation available on [Rubydoc.info][EBNF doc].
103
108
 
104
109
  ## Future Work
105
- * Generate HTML output of parser results.
106
110
  * Better LL(1) parser tests
107
111
  * Either generate [Packrat parser][Packrat] for a [Parsing Regular Expression Grammar][PEG], or integrate with [Treetop][] or similar.
108
112
 
@@ -144,3 +148,4 @@ A copy of the [Turtle EBNF][] and derived parser files are included in the repos
144
148
  [Packrat]: http://pdos.csail.mit.edu/~baford/packrat/thesis/
145
149
  [PEG]: http://en.wikipedia.org/wiki/Parsing_expression_grammar
146
150
  [Treetop]: http://rubygems.org/gems/treetop
151
+ [Haml]: http://rubygems.org/gems/haml
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.8
1
+ 0.3.9
data/lib/ebnf/writer.rb CHANGED
@@ -76,13 +76,17 @@ module EBNF
76
76
 
77
77
  if @options[:html]
78
78
  # Output as formatted HTML
79
- require 'haml'
80
- html = Haml::Engine.new(HAML_DESC).render(self, rules: rules) do |rule|
81
- formatted_expr = format(rule.expr)
82
- formatted_expr.length > rhs_length ? format(rule.expr, "\n") : formatted_expr
79
+ begin
80
+ require 'haml'
81
+ html = Haml::Engine.new(HAML_DESC).render(self, rules: rules) do |rule|
82
+ formatted_expr = format(rule.expr)
83
+ formatted_expr.length > rhs_length ? format(rule.expr, "\n") : formatted_expr
84
+ end
85
+ out.write html
86
+ return
87
+ rescue LoadError
88
+ $stderr.puts "Generating HTML requires haml gem to be loaded"
83
89
  end
84
- out.write html
85
- return
86
90
  end
87
91
 
88
92
  # Format each rule, considering the available rhs size
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ebnf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregg Kellogg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-26 00:00:00.000000000 Z
11
+ date: 2015-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sxp
@@ -51,7 +51,7 @@ dependencies:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
53
  version: '4.0'
54
- type: :runtime
54
+ type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements: