Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Version 1.1.0 commit. Also added treeetop rake task to generate .tree…
…top files
- Loading branch information
Showing
3 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
# Autogenerated from a Treetop grammar. Edits may be lost. | ||
|
||
|
||
module Mail | ||
module ContentLocation | ||
include Treetop::Runtime | ||
|
||
def root | ||
@root || :primary | ||
end | ||
|
||
include RFC2822 | ||
|
||
include RFC2045 | ||
|
||
module Primary0 | ||
def CFWS1 | ||
elements[0] | ||
end | ||
|
||
def location | ||
elements[1] | ||
end | ||
|
||
def CFWS2 | ||
elements[2] | ||
end | ||
end | ||
|
||
def _nt_primary | ||
start_index = index | ||
if node_cache[:primary].has_key?(index) | ||
cached = node_cache[:primary][index] | ||
@index = cached.interval.end if cached | ||
return cached | ||
end | ||
|
||
i0, s0 = index, [] | ||
r1 = _nt_CFWS | ||
s0 << r1 | ||
if r1 | ||
r2 = _nt_location | ||
s0 << r2 | ||
if r2 | ||
r3 = _nt_CFWS | ||
s0 << r3 | ||
end | ||
end | ||
if s0.last | ||
r0 = instantiate_node(SyntaxNode,input, i0...index, s0) | ||
r0.extend(Primary0) | ||
else | ||
@index = i0 | ||
r0 = nil | ||
end | ||
|
||
node_cache[:primary][start_index] = r0 | ||
|
||
r0 | ||
end | ||
|
||
module Location0 | ||
def text_value | ||
quoted_content.text_value | ||
end | ||
end | ||
|
||
def _nt_location | ||
start_index = index | ||
if node_cache[:location].has_key?(index) | ||
cached = node_cache[:location][index] | ||
@index = cached.interval.end if cached | ||
return cached | ||
end | ||
|
||
i0 = index | ||
r1 = _nt_quoted_string | ||
r1.extend(Location0) | ||
if r1 | ||
r0 = r1 | ||
else | ||
s2, i2 = [], index | ||
loop do | ||
i3 = index | ||
r4 = _nt_token | ||
if r4 | ||
r3 = r4 | ||
else | ||
if has_terminal?('\G[\\x3d]', true, index) | ||
r5 = true | ||
@index += 1 | ||
else | ||
r5 = nil | ||
end | ||
if r5 | ||
r3 = r5 | ||
else | ||
@index = i3 | ||
r3 = nil | ||
end | ||
end | ||
if r3 | ||
s2 << r3 | ||
else | ||
break | ||
end | ||
end | ||
if s2.empty? | ||
@index = i2 | ||
r2 = nil | ||
else | ||
r2 = instantiate_node(SyntaxNode,input, i2...index, s2) | ||
end | ||
if r2 | ||
r0 = r2 | ||
else | ||
@index = i0 | ||
r0 = nil | ||
end | ||
end | ||
|
||
node_cache[:location][start_index] = r0 | ||
|
||
r0 | ||
end | ||
|
||
end | ||
|
||
class ContentLocationParser < Treetop::Runtime::CompiledParser | ||
include ContentLocation | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace :treetop do | ||
|
||
desc "Pre-generate all the .treetop files into .rb files" | ||
task :generate do | ||
Dir[File.join(File.dirname(__FILE__), '..', 'mail', 'parsers', '*.treetop')].each do |filename| | ||
`tt #{filename}` | ||
end | ||
end | ||
|
||
end |