crokus 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dcb68605a201bca25f5f843ace95ff078e9a0d2ede923847a7a21f8fcc99377d
4
- data.tar.gz: 0754e6251c17663e2206c01e494c0dbb148bdb9329ffc7df1fa06e89a399c8d4
3
+ metadata.gz: cc241276f39be6875db2caf5b00a5a4922906163c97bbe183d0e05dd697162c1
4
+ data.tar.gz: 1491b17c9072e7c1c52a7dc136b3a604444a36ff39548754eb3ca87654e20b6a
5
5
  SHA512:
6
- metadata.gz: d62a9ad0c30d023374bfb14319e3cab47124e7983f7a62eb24d939625ea8fbf0d40795c4ffe8bf9aa08fa4715cef20560f3ed274304d1c0d7ea168e00302bede
7
- data.tar.gz: 550b3d0f5c214c3c13c218a1759becfe5812b24e2426ab54cc4dae6a14a37f168876a7ecfbbb09a010b9ebfc98a8e8fb28ac44dccbe1757e4e448d522c9132bb
6
+ metadata.gz: 6d2f4763cf304256a1a08ab6974535e5c6448e354eeef787389e1c27424c276268a6cf3b702428c68dafbc8b60f260d143f39b52634152ccd0302537989bf073
7
+ data.tar.gz: 9b9d32f8346b783b960c8a4ff077b2d01e001833adbfb72e9c7e3d8961428a894be8e55adba1a39eb6b6932b7b55db41c8822cf743cad742f9278d249a250a26
data/bin/crokus CHANGED
File without changes
@@ -35,7 +35,7 @@ module Crokus
35
35
  @bbs << bb
36
36
  end
37
37
 
38
- def print
38
+ def print versbose=false
39
39
  CFGPrinter.new.print(self,5)
40
40
  end
41
41
 
@@ -2,15 +2,17 @@ module Crokus
2
2
 
3
3
  class PrinterC
4
4
 
5
- attr_accessor :cfg
5
+ attr_accessor :cfg, :options
6
6
 
7
- def initialize
7
+ def initialize options={}
8
+ @options=options
8
9
  @visited=[]
9
10
  @prp=PrettyPrinter.new
10
11
  end
11
12
 
12
13
  def print cfg
13
- puts " |-->[+] generating C code from cfg '#{cfg.name}'"
14
+ filename= "#{cfg.name}.c"
15
+ puts " |-->[+] generating C code from cfg '#{cfg.name}' in '#{filename}'"
14
16
  @cfg=cfg
15
17
  code=Code.new
16
18
  code << "//"+"-"*60
@@ -34,8 +36,8 @@ module Crokus
34
36
  code << "}"
35
37
  code.newline
36
38
  code << main(cfg)
37
- puts code.finalize
38
- code.save_as "#{cfg.name}.c"
39
+ puts code.finalize if options[:verbose]
40
+ code.save_as filename
39
41
  end
40
42
 
41
43
  def main cfg
@@ -13,10 +13,15 @@ end
13
13
  module Crokus
14
14
 
15
15
  class RandomGen
16
+ attr_accessor :options
16
17
  attr_accessor :cfg
17
18
 
19
+ def initialize options={}
20
+ @options=options
21
+ end
22
+
18
23
  def run params
19
- puts "[+] running random Newage code generation"
24
+ puts "[+] running random C code generation"
20
25
  puts " |-->[+] reading parameters file '#{params}'"
21
26
  @params=YAML.load(File.read(params))
22
27
  init_cfg
@@ -30,7 +35,7 @@ module Crokus
30
35
  gen_dot # to see the structure, before hacking the content
31
36
  populate_all
32
37
  generate_c
33
- #print_infos
38
+ print_infos
34
39
  end
35
40
 
36
41
 
@@ -306,7 +311,7 @@ module Crokus
306
311
  end
307
312
 
308
313
  def generate_c
309
- PrinterC.new.print(cfg)
314
+ PrinterC.new(options).print(cfg)
310
315
  end
311
316
  end
312
317
  end
@@ -28,6 +28,8 @@ module Crokus
28
28
  parse(filename)
29
29
  return true if options[:parse_only]
30
30
 
31
+ draw_ast(@ast) if options[:ast]
32
+
31
33
  build_cfg
32
34
  return true if options[:cfg]
33
35
 
@@ -55,7 +57,7 @@ module Crokus
55
57
  end
56
58
 
57
59
  def draw_ast tree=nil,filename=nil
58
- dotname=filename || "#{base_name}.dot"
60
+ dotname=filename || "#{base_name}_ast.dot"
59
61
  puts " |--[+] drawing AST '#{dotname}'" unless options[:mute]
60
62
  ast_ = tree || @ast
61
63
  dot=AstPrinter.new.print(ast_)
@@ -194,7 +194,7 @@ module Crokus
194
194
  if assign.rhs.is_a? Parenth
195
195
  rhs=assign.rhs.expr.accept(self)
196
196
  end
197
- ret="#{lhs} #{op} #{rhs}"
197
+ ret="#{lhs} #{op} #{rhs};"
198
198
  ret
199
199
  end
200
200
 
@@ -69,10 +69,6 @@ module Crokus
69
69
  options[:random] = params_filename
70
70
  end
71
71
 
72
- # parser.on('--trojan PARAMS', "generates random c files, using parameters", String) do |params_filename|
73
- # options[:trojan] = params_filename
74
- # end
75
-
76
72
  parser.on('--trojan', "generates random c files, using parameters") do
77
73
  options[:trojan] = true
78
74
  end
@@ -1,3 +1,3 @@
1
1
  module Crokus
2
- VERSION="0.1.2"
2
+ VERSION="0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crokus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Christophe Le Lann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-12 00:00:00.000000000 Z
11
+ date: 2020-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: distribution