tp_plus 0.0.75 → 0.0.76

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 715a2b6920c4a27cba58ad07cdef950bce8dc85b
4
- data.tar.gz: 1d67bbde251dd3dc0c84f346b49cce19c07bcf45
3
+ metadata.gz: 7347bb879e0d8008d909ad4888596f07697bd0f4
4
+ data.tar.gz: bb148385881540ada26d78565576dc8ce8df7acc
5
5
  SHA512:
6
- metadata.gz: 83cbd62b3807e17cc20bfb6d4f426197f6d8da570628bb9e89d6e5f95b135b190b2e08283c483d3afa9f26a6d21e2e762360fd0ec6b45f93f68dc1346f6b8713
7
- data.tar.gz: 5514468372d3b436202ac3f4a80f86fe0f0c5365408e124db71c13d03139a3b4bc70abc120b89c37cbb595f482a96d88a9399e4fb8431d86a0eedefe0b004973
6
+ metadata.gz: 786218479e3e4bdee08f867f8d97d04dc73052bdbec3c686088d1dc2d384a3a302d57a479e55facf754b745073f5b75bcd0b09397cc327aa23631d449cb46067
7
+ data.tar.gz: ad566ce1eab3649796fb06b1e2963a7749c7ee28548e476086941f40b540883c7117e876418648d8b5beec83b129b5a59ef74a4c9f70790f2275687060edfc5a
data/README.md CHANGED
@@ -46,16 +46,16 @@ example_1.ls
46
46
 
47
47
  /PROG example_1
48
48
  /MN
49
- 1: R[1:foo] = 1 ;
50
- 1: ;
51
- 1: LBL[100:loop] ;
52
- 1: R[1:foo]=R[1:foo]+1 ;
53
- 1: IF R[1:foo]<10,JMP LBL[100] ;
54
- 1: ;
55
- 1: IF (R[1:foo]=5),DO[1:bar]=(ON) ;
56
- 1: DO[2:baz]=(!DO[2:baz]) ;
57
- 1: ;
58
- 1: L PR[1:home] 2000mm/sec CNT0 ;
49
+ : R[1:foo] = 1 ;
50
+ : ;
51
+ : LBL[100:loop] ;
52
+ : R[1:foo]=R[1:foo]+1 ;
53
+ : IF R[1:foo]<10,JMP LBL[100] ;
54
+ : ;
55
+ : IF (R[1:foo]=5),DO[1:bar]=(ON) ;
56
+ : DO[2:baz]=(!DO[2:baz]) ;
57
+ : ;
58
+ : L PR[1:home] 2000mm/sec CNT0 ;
59
59
  /END
60
60
 
61
61
  For a more extensive example and test environment, visit http://tp-plus.herokuapp.com/.
@@ -64,7 +64,7 @@ Usage
64
64
  -----
65
65
 
66
66
  1. `gem install tp_plus`
67
- 2. `tpp filename.tpp > filename.ls`
67
+ 2. `tpp filename.tpp -o filename.ls`
68
68
 
69
69
  See `tpp --help` for options.
70
70
 
data/bin/tpp CHANGED
@@ -1,24 +1,44 @@
1
1
  #!/usr/bin/env ruby
2
- require 'tp_plus'
2
+ require_relative '../lib/tp_plus'
3
3
  require 'optparse'
4
4
 
5
5
  options = {}
6
6
  OptionParser.new do |opts|
7
7
  opts.banner = "Usage: tpp [options] filename"
8
8
 
9
- opts.on("-e", "--environment env_file.tpp", "Require an environment file before parsing files") do |e|
9
+ opts.on("-e", "--environment <file>", "Require an environment file <file> before parsing") do |e|
10
10
  options[:environment] = e
11
11
  end
12
12
 
13
+ opts.on("-o", "--output <file>", "Write output to <file>") do |o|
14
+ options[:output] = o
15
+ end
16
+
13
17
  opts.on_tail("-h", "--help", "Show this message") do
14
18
  puts opts
15
19
  exit
16
20
  end
17
21
  end.parse!
18
22
 
23
+ if ARGV.length != 1
24
+ puts "Must provide filename argument. See tpp --help for details"
25
+ exit
26
+ end
27
+
28
+ tpp_filename = File.basename(ARGV[0],".*")
29
+
30
+ if options[:output]
31
+ # ensure filename matches (FANUC parser will complain otherwise)
32
+ output_filename = File.basename(options[:output], ".*")
33
+ if output_filename != tpp_filename
34
+ puts "Output filename <#{output_filename}> does not match input filename <#{tpp_filename}>"
35
+ exit
36
+ end
37
+ end
38
+
19
39
  def contents(filename)
20
40
  if !File.exist?(filename)
21
- puts "File (#{filename}) does not exist"
41
+ puts "File <#{filename}> does not exist"
22
42
  exit
23
43
  end
24
44
  f = File.open(filename,'rb')
@@ -34,11 +54,6 @@ if options[:environment]
34
54
  interpreter.load_environment(contents(options[:environment]))
35
55
  end
36
56
 
37
- if ARGV.length != 1
38
- puts "Must provide filename argument. See tpp --help for details"
39
- exit
40
- end
41
-
42
57
  src = contents(ARGV[0])
43
58
 
44
59
  scanner.scan_setup(src)
@@ -46,7 +61,6 @@ parser.parse
46
61
 
47
62
  lines = interpreter.eval
48
63
 
49
- tpp_filename = File.basename(ARGV[0],".*")
50
64
  output = %(/PROG #{tpp_filename.upcase}
51
65
  /ATTR
52
66
  COMMENT = "#{interpreter.header_data[:comment] || tpp_filename.upcase}";
@@ -70,4 +84,9 @@ end
70
84
 
71
85
  output += %(/END\n)
72
86
 
73
- print output
87
+ if options[:output]
88
+ # write to file
89
+ File.write(options[:output], output)
90
+ else
91
+ print output
92
+ end
@@ -1,4 +1,4 @@
1
- require 'tp_plus/parser'
1
+ require_relative 'parser'
2
2
 
3
3
  module TPPlus
4
4
  class Interpreter
@@ -18,6 +18,8 @@ module TPPlus
18
18
  return false if @ids.include?(position_hash[:id])
19
19
  @ids.push(position_hash[:id])
20
20
 
21
+ return false unless position_hash[:mask].is_a? Array
22
+
21
23
  position_hash[:mask].select {|q|
22
24
  !mask_valid?(q)
23
25
  }.empty?
@@ -1,3 +1,3 @@
1
1
  module TPPlus
2
- VERSION = '0.0.75'
2
+ VERSION = '0.0.76'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tp_plus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.75
4
+ version: 0.0.76
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jay Strybis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-12 00:00:00.000000000 Z
11
+ date: 2015-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark-ips