fop_lang 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/fop +31 -0
- data/lib/fop/cli.rb +30 -0
- data/lib/fop/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cfe0a53d59b00d2fc60f0c0f5ed3e413eb61cf0ae445d49562f0cf861cd9f0b
|
4
|
+
data.tar.gz: 5aa04d8145417d52b42847be17b54a230242143486278d2826adacb7d1143101
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79efdf103e6e33bc508df356e2295ac49c8f112ad44a0c3aad4209bb204fadcd240b12f14f62ee3266d21762afec1e8a3262b767fda42cc7ebf019688bfbe30e
|
7
|
+
data.tar.gz: 1f424bf43332438a3f223af0737fa6570de8e06444669edd8808e5d41e2804fe9139598f58336ca098a1b67fba8741519375e3700916747acb8df6ddace3294d
|
data/bin/fop
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Used for local testing
|
4
|
+
# $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
5
|
+
|
6
|
+
require 'fop_lang'
|
7
|
+
require 'fop/cli'
|
8
|
+
|
9
|
+
opts = Fop::CLI.options!
|
10
|
+
src = opts.src.read.chomp
|
11
|
+
fop, errors = Fop.compile(src)
|
12
|
+
opts.src.close
|
13
|
+
NL = "\n".freeze
|
14
|
+
|
15
|
+
if errors
|
16
|
+
$stderr.puts src
|
17
|
+
$stderr.puts errors.join(NL)
|
18
|
+
exit 1
|
19
|
+
end
|
20
|
+
|
21
|
+
if opts.check
|
22
|
+
$stdout.puts "Syntax OK" unless opts.quiet
|
23
|
+
exit 0
|
24
|
+
end
|
25
|
+
|
26
|
+
while (line = gets) do
|
27
|
+
line.chomp!
|
28
|
+
if (res = fop.apply(line))
|
29
|
+
print(res << NL)
|
30
|
+
end
|
31
|
+
end
|
data/lib/fop/cli.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
module Fop
|
4
|
+
module CLI
|
5
|
+
Options = Struct.new(:src, :check, :quiet)
|
6
|
+
|
7
|
+
def self.options!
|
8
|
+
options = Options.new
|
9
|
+
OptionParser.new do |opts|
|
10
|
+
opts.banner = "Usage: fop [options] [ 'prog' | -f progfile ] [ file ... ]"
|
11
|
+
|
12
|
+
opts.on("-fFILE", "--file=FILE", "Read program from file instead of first argument") do |f|
|
13
|
+
options.src = File.open(f)
|
14
|
+
options.src.advise(:sequential)
|
15
|
+
end
|
16
|
+
|
17
|
+
opts.on("-c", "--check", "Perform a syntax check on the program and exit") do
|
18
|
+
options.check = true
|
19
|
+
end
|
20
|
+
|
21
|
+
opts.on("-q", "--quiet") do
|
22
|
+
options.quiet = true
|
23
|
+
end
|
24
|
+
end.parse!
|
25
|
+
|
26
|
+
options.src ||= StringIO.new(ARGV.shift)
|
27
|
+
options
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/fop/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fop_lang
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordan Hollinger
|
@@ -12,11 +12,14 @@ date: 2021-08-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
13
13
|
description: A micro expression language for Filter and OPerations on text
|
14
14
|
email: jordan.hollinger@gmail.com
|
15
|
-
executables:
|
15
|
+
executables:
|
16
|
+
- fop
|
16
17
|
extensions: []
|
17
18
|
extra_rdoc_files: []
|
18
19
|
files:
|
19
20
|
- README.md
|
21
|
+
- bin/fop
|
22
|
+
- lib/fop/cli.rb
|
20
23
|
- lib/fop/compiler.rb
|
21
24
|
- lib/fop/nodes.rb
|
22
25
|
- lib/fop/parser.rb
|