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 +4 -4
- data/bin/crokus +0 -0
- data/lib/crokus/cfg.rb +1 -1
- data/lib/crokus/cfg_printer_c.rb +7 -5
- data/lib/crokus/cfg_random_gen.rb +8 -3
- data/lib/crokus/compiler.rb +3 -1
- data/lib/crokus/pretty_printer.rb +1 -1
- data/lib/crokus/runner.rb +0 -4
- data/lib/crokus/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc241276f39be6875db2caf5b00a5a4922906163c97bbe183d0e05dd697162c1
|
4
|
+
data.tar.gz: 1491b17c9072e7c1c52a7dc136b3a604444a36ff39548754eb3ca87654e20b6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d2f4763cf304256a1a08ab6974535e5c6448e354eeef787389e1c27424c276268a6cf3b702428c68dafbc8b60f260d143f39b52634152ccd0302537989bf073
|
7
|
+
data.tar.gz: 9b9d32f8346b783b960c8a4ff077b2d01e001833adbfb72e9c7e3d8961428a894be8e55adba1a39eb6b6932b7b55db41c8822cf743cad742f9278d249a250a26
|
data/bin/crokus
CHANGED
File without changes
|
data/lib/crokus/cfg.rb
CHANGED
data/lib/crokus/cfg_printer_c.rb
CHANGED
@@ -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
|
-
|
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
|
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
|
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
|
-
|
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
|
data/lib/crokus/compiler.rb
CHANGED
@@ -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_)
|
data/lib/crokus/runner.rb
CHANGED
@@ -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
|
data/lib/crokus/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2020-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: distribution
|