jison 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/jison.rb +17 -0
- data/lib/jison/execution_error.rb +10 -0
- data/lib/jison/version.rb +43 -0
- metadata +48 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c90e93099a37058ff03c8a234fca8a5fc8a44770
|
4
|
+
data.tar.gz: 877425fba83c9d667b4cae0c995e004f08c6f47f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4ef21c4e0d28be3758db28929f1adcea509fed94a7a839923d566eda4c63258c98503d2f7839162a96e8f30329346d9643ccd59d9473cdcb983b4315ef17ed04
|
7
|
+
data.tar.gz: 3dc527835a8f2f87cdb7f5132d03c8365997a102b58b1ea22bee3b32809f2ca0c98f19b41a28b66b76585ceede0ee50cbf0b47f69ce945e914ea5822daf4c8f4
|
data/lib/jison.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'open3'
|
2
|
+
require 'jison/execution_error'
|
3
|
+
require 'jison/version'
|
4
|
+
|
5
|
+
module Jison
|
6
|
+
class << self
|
7
|
+
def version
|
8
|
+
Version.from_string `jison --version`
|
9
|
+
end
|
10
|
+
|
11
|
+
def parse(grammar)
|
12
|
+
stdout, stderr, status = Open3.capture3('jison', :stdin_data => grammar)
|
13
|
+
return stdout if status.exitstatus.zero?
|
14
|
+
raise ExecutionError.new(stderr, status.exitstatus)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Jison
|
2
|
+
class Version
|
3
|
+
include Comparable
|
4
|
+
|
5
|
+
attr_reader :major, :minor, :micro
|
6
|
+
|
7
|
+
def self.from_string(string)
|
8
|
+
version = string.gsub(/^\s+|\s+$/, '').split('.').map(&:to_i)
|
9
|
+
new(*version)
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(major, minor=0, micro=0)
|
13
|
+
@major, @minor, @micro = major, minor, micro
|
14
|
+
end
|
15
|
+
|
16
|
+
def ==(other)
|
17
|
+
major == other.major \
|
18
|
+
&& minor == other.minor \
|
19
|
+
&& micro == other.micro
|
20
|
+
end
|
21
|
+
|
22
|
+
def <=>(other)
|
23
|
+
case other
|
24
|
+
when Version
|
25
|
+
cmp = major - other.major
|
26
|
+
return cmp unless cmp.zero?
|
27
|
+
cmp = minor - other.minor
|
28
|
+
return cmp unless cmp.zero?
|
29
|
+
micro - other.micro
|
30
|
+
when String
|
31
|
+
self <=> Version.from_string(other)
|
32
|
+
when Fixnum
|
33
|
+
major - other
|
34
|
+
else
|
35
|
+
raise RuntimeError.new("Cannot compare against #{other.class}: #{other.inspect}")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_s
|
40
|
+
"#{major}.#{minor}.#{micro}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
metadata
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jison
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dylon Edwards
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-01 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: |2
|
14
|
+
Wrapper around the jison, npm module that compiles Jison grammars and
|
15
|
+
returns the corresponding, JavaScript text.
|
16
|
+
email: dylon.edwards@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/jison/version.rb
|
22
|
+
- lib/jison/execution_error.rb
|
23
|
+
- lib/jison.rb
|
24
|
+
homepage: https://github.com/dylon/ruby-jison
|
25
|
+
licenses:
|
26
|
+
- MIT
|
27
|
+
metadata: {}
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
require_paths:
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubyforge_project:
|
44
|
+
rubygems_version: 2.0.14
|
45
|
+
signing_key:
|
46
|
+
specification_version: 4
|
47
|
+
summary: Ruby, Jison Compiler
|
48
|
+
test_files: []
|