teepee 0.17.0 → 0.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/teepee/command-parser.rb +9 -5
- data/lib/teepee/list-parser.rb +91 -0
- data/lib/teepee/paragraph-parser.rb +6 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 728d9d50f5037e176591834141724345721e6013
|
4
|
+
data.tar.gz: e243574356bbbc92b7992e7b74adf00d7b38783a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbab2447521fab020fa8bac262c35b487d50a7eaf94d936f0922ee7f834d37d42c18ec5b79f7487350c8238e2df7b247e4ab2db4e88629fb93f2094423009aba
|
7
|
+
data.tar.gz: 649d0a5561c83bf40c18955e96e1c0eecdcac2e91cbb5d1dd5da900f5947814a866ed20b614b9f5789cbb1238775e0d760b738cd5b0eedc5bd4d0fa34b39de4d
|
@@ -43,13 +43,14 @@ require 'teepee/errors'
|
|
43
43
|
require 'teepee/parser-node'
|
44
44
|
require 'teepee/commander'
|
45
45
|
require 'teepee/actionable-commander'
|
46
|
+
require 'teepee/list-parser'
|
46
47
|
|
47
48
|
module Teepee
|
48
49
|
class CommandParser < ParserNode
|
49
|
-
attr_accessor :parser, :scope
|
50
|
-
attr_reader :command, :expressions
|
50
|
+
attr_accessor :command, :expressions, :parser, :scope
|
51
51
|
|
52
52
|
def initialize(parser, scope, command, expressions)
|
53
|
+
raise ArgumentError if not parser.is_a? Parser
|
53
54
|
@parser = parser
|
54
55
|
raise ArgumentError if not command.is_a? WordToken
|
55
56
|
@scope = scope
|
@@ -522,9 +523,12 @@ module Teepee
|
|
522
523
|
return [CommandParser.new(parser, scope, command, []), rest]
|
523
524
|
end
|
524
525
|
while rest.length > 0
|
525
|
-
if rest.first.is_a?
|
526
|
-
|
527
|
-
|
526
|
+
if rest.first.is_a? LeftBraceToken
|
527
|
+
list, rest = ListParser.parse parser, scope.derive, rest
|
528
|
+
expressions << list
|
529
|
+
elsif rest.first.is_a? WordToken or
|
530
|
+
rest.first.is_a? WhitespaceToken or
|
531
|
+
rest.first.is_a? PipeToken
|
528
532
|
expressions << rest.shift
|
529
533
|
elsif rest.first.is_a? BackslashToken
|
530
534
|
result, rest = CommandParser.parse(parser, scope, rest)
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# -*- mode: Ruby -*-
|
3
|
+
|
4
|
+
# Copyright © 2013-2016, Christopher Mark Gore,
|
5
|
+
# Soli Deo Gloria,
|
6
|
+
# All rights reserved.
|
7
|
+
#
|
8
|
+
# 2317 South River Road, Saint Charles, Missouri 63303 USA.
|
9
|
+
# Web: http://cgore.com
|
10
|
+
# Email: cgore@cgore.com
|
11
|
+
#
|
12
|
+
# Redistribution and use in source and binary forms, with or without
|
13
|
+
# modification, are permitted provided that the following conditions are met:
|
14
|
+
#
|
15
|
+
# * Redistributions of source code must retain the above copyright
|
16
|
+
# notice, this list of conditions and the following disclaimer.
|
17
|
+
#
|
18
|
+
# * Redistributions in binary form must reproduce the above copyright
|
19
|
+
# notice, this list of conditions and the following disclaimer in the
|
20
|
+
# documentation and/or other materials provided with the distribution.
|
21
|
+
#
|
22
|
+
# * Neither the name of Christopher Mark Gore nor the names of other
|
23
|
+
# contributors may be used to endorse or promote products derived from
|
24
|
+
# this software without specific prior written permission.
|
25
|
+
#
|
26
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
27
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
28
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
29
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
30
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
31
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
32
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
33
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
34
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
35
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
36
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
37
|
+
|
38
|
+
module Teepee
|
39
|
+
class ListParser < ParserNode
|
40
|
+
attr_accessor :parser, :scope, :expressions
|
41
|
+
|
42
|
+
def initialize parser, scope, expressions
|
43
|
+
raise ArgumentError if not parser.is_a? Parser
|
44
|
+
@parser = parser
|
45
|
+
raise ArgumentError if not scope.is_a? Scope
|
46
|
+
@scope = scope
|
47
|
+
expressions.each do |expression|
|
48
|
+
raise ArgumentError if not expression.kind_of? ParserNode
|
49
|
+
end
|
50
|
+
@expressions = expressions
|
51
|
+
end
|
52
|
+
|
53
|
+
def to_html
|
54
|
+
"{" + expressions.map(&:to_html).join(" ") + "}"
|
55
|
+
end
|
56
|
+
|
57
|
+
def use_scope scope
|
58
|
+
@scope = scope
|
59
|
+
expressions.map {|node| node.use_scope scope}
|
60
|
+
end
|
61
|
+
|
62
|
+
class << self
|
63
|
+
def parse parser, scope, tokens
|
64
|
+
expressions = []
|
65
|
+
rest = tokens
|
66
|
+
left_brace = rest.shift
|
67
|
+
right_brace = nil
|
68
|
+
raise ParseError if not left_brace.is_a? LeftBraceToken
|
69
|
+
while rest.length > 0
|
70
|
+
if rest.first.is_a? LeftBraceToken
|
71
|
+
list, rest = ListParser.parse parser, scope.derive, rest
|
72
|
+
expressions << list
|
73
|
+
elsif rest.first.is_a? WordToken or
|
74
|
+
rest.first.is_a? PipeToken
|
75
|
+
expressions << rest.shift
|
76
|
+
elsif rest.first.is_a? WhitespaceToken
|
77
|
+
rest.shift # Drop the whitespace, this is the list separator.
|
78
|
+
elsif rest.first.is_a? BackslashToken
|
79
|
+
result, rest = CommandParser.parse parser, scope, rest
|
80
|
+
expressions << result
|
81
|
+
elsif rest.first.is_a? RightBraceToken
|
82
|
+
right_brace = rest.shift
|
83
|
+
return [ListParser.new(parser, scope, expressions), rest]
|
84
|
+
else
|
85
|
+
raise ParseError
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -45,12 +45,14 @@ require 'teepee/string-token'
|
|
45
45
|
require 'teepee/number-token'
|
46
46
|
require 'teepee/tokenizer'
|
47
47
|
require 'teepee/command-parser'
|
48
|
+
require 'teepee/list-parser'
|
48
49
|
|
49
50
|
module Teepee
|
50
51
|
class ParagraphParser < ParserNode
|
51
52
|
attr_accessor :expressions, :parser, :scope, :tokens
|
52
53
|
|
53
54
|
def initialize(parser, tokens)
|
55
|
+
raise ArgumentError if not parser.is_a? Parser
|
54
56
|
@parser = parser
|
55
57
|
@scope = Scope.new
|
56
58
|
raise ArgumentError if not tokens.is_a? Array
|
@@ -63,7 +65,10 @@ module Teepee
|
|
63
65
|
@expressions = []
|
64
66
|
rest = tokens
|
65
67
|
while rest.length > 0
|
66
|
-
if rest.first.is_a?
|
68
|
+
if rest.first.is_a? LeftBraceToken
|
69
|
+
list, rest = ListParser.parse parser, scope.derive, rest
|
70
|
+
@expressions << list
|
71
|
+
elsif rest.first.is_a? WordToken
|
67
72
|
@expressions << rest.shift
|
68
73
|
elsif rest.first.is_a? WhitespaceToken
|
69
74
|
@expressions << rest.shift
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: teepee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.17.
|
4
|
+
version: 0.17.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Mark Gore
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- lib/teepee/commander.rb
|
84
84
|
- lib/teepee/constants.rb
|
85
85
|
- lib/teepee/errors.rb
|
86
|
+
- lib/teepee/list-parser.rb
|
86
87
|
- lib/teepee/number-token.rb
|
87
88
|
- lib/teepee/paragraph-parser.rb
|
88
89
|
- lib/teepee/parser-node.rb
|