nasl 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/lib/nasl/grammar.racc +5 -3
- data/lib/nasl/parser/function.rb +15 -4
- data/lib/nasl/version.rb +1 -1
- data/test/unit/parser/test_object.rb +23 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba5d4713f9f37ff1cef35443d8e0a7befdf7a8ab
|
4
|
+
data.tar.gz: 90c08ad08a102e283f0313a422af423c043cc775
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b18b5139c6eb7acc431cf003184f47d587fbc05908aa1f972f8908dd0da42c1e295827408042295e8ca654a60e6872b89d835d067b6098fb4b61aa824c54b8e
|
7
|
+
data.tar.gz: dbecc5c082b505176925ff1f9d0d8e7b8ac47b1ac9445eaf330dc120693b679853287b6ecae7fd55ce960cb97a9ae4f46270b65206abf3df3c2963431535104e
|
data/lib/nasl/grammar.racc
CHANGED
@@ -122,6 +122,10 @@ rule
|
|
122
122
|
{ n(:Function, val[0], 'obj', val[1], val[2], val[3], val[4], val[5], val[6]) }
|
123
123
|
| obj_func_attr FUNCTION ident LPAREN RPAREN block
|
124
124
|
{ n(:Function, val[0], 'obj', val[1], val[2], val[3], val[4], val[5]) }
|
125
|
+
| FUNCTION ident LPAREN params RPAREN block
|
126
|
+
{ n(:Function, val[0], 'obj', val[1], val[2], val[3], val[4], val[5]) }
|
127
|
+
| FUNCTION ident LPAREN RPAREN block
|
128
|
+
{ n(:Function, val[0], 'obj', val[1], val[2], val[3], val[4]) }
|
125
129
|
;
|
126
130
|
|
127
131
|
function : FUNCTION ident LPAREN params RPAREN block
|
@@ -261,9 +265,7 @@ rule
|
|
261
265
|
{ n(:Return, *val) }
|
262
266
|
;
|
263
267
|
|
264
|
-
obj_func_attr :
|
265
|
-
{ nil }
|
266
|
-
| PUBLIC
|
268
|
+
obj_func_attr : PUBLIC
|
267
269
|
{ val[0] }
|
268
270
|
| PRIVATE
|
269
271
|
{ val[0] }
|
data/lib/nasl/parser/function.rb
CHANGED
@@ -34,16 +34,27 @@ module Nasl
|
|
34
34
|
super
|
35
35
|
|
36
36
|
@body = @tokens.last
|
37
|
-
|
38
37
|
@fn_type = @tokens[1]
|
39
38
|
|
40
39
|
if @fn_type == "obj"
|
41
|
-
@name = @tokens[3]
|
42
|
-
@attribute = @tokens[0]
|
43
40
|
if @tokens.length == 8
|
41
|
+
@name = @tokens[3]
|
42
|
+
@attribute = @tokens[0]
|
44
43
|
@params = @tokens[5]
|
45
|
-
|
44
|
+
elsif @tokens.length == 7
|
45
|
+
if @tokens[0].is_a?(Token) && @tokens[0].type == :FUNCTION
|
46
|
+
@attribute = nil
|
47
|
+
@params = @tokens[4]
|
48
|
+
@name = @tokens[2]
|
49
|
+
else
|
50
|
+
@name = @tokens[3]
|
51
|
+
@attribute = @tokens[0]
|
52
|
+
@params = []
|
53
|
+
end
|
54
|
+
elsif @tokens.length == 6
|
55
|
+
@attribute = nil
|
46
56
|
@params = []
|
57
|
+
@name = @tokens[2]
|
47
58
|
end
|
48
59
|
else
|
49
60
|
@name = @tokens[2]
|
data/lib/nasl/version.rb
CHANGED
@@ -37,11 +37,15 @@ namespace test {
|
|
37
37
|
var a1,b1;
|
38
38
|
# foo
|
39
39
|
public function bar_pub() {}
|
40
|
+
public function bar_pub1(foo) {}
|
41
|
+
|
40
42
|
# foo
|
41
43
|
function bar_priv_default() { a = 1; return a; }
|
42
44
|
private function bar_priv() {}
|
45
|
+
function test_bar1(foo) {}
|
46
|
+
|
43
47
|
# foo
|
44
|
-
function
|
48
|
+
function test_bar()
|
45
49
|
{
|
46
50
|
var test = 'a';
|
47
51
|
var x,y,z,t;
|
@@ -52,7 +56,7 @@ namespace test {
|
|
52
56
|
function foo(){}
|
53
57
|
}
|
54
58
|
# foo!
|
55
|
-
function
|
59
|
+
function foo1(){}
|
56
60
|
EOF
|
57
61
|
)
|
58
62
|
assert_not_nil(tree)
|
@@ -62,11 +66,25 @@ function foo(){}
|
|
62
66
|
assert_equal(objects[0].name.name, "foo")
|
63
67
|
|
64
68
|
functions = tree.all(:Function)
|
65
|
-
assert_equal(
|
69
|
+
assert_equal(8, functions.length)
|
66
70
|
|
67
71
|
assert_equal(functions[0].tokens[0].type.to_s, "PUBLIC")
|
68
|
-
assert_equal(functions[
|
69
|
-
|
72
|
+
assert_equal(functions[3].tokens[0].type.to_s, "PRIVATE")
|
73
|
+
|
74
|
+
# private / public object functions, no args
|
75
|
+
assert_equal(functions[0].name.name, "bar_pub")
|
76
|
+
assert_equal(functions[3].name.name, "bar_priv")
|
77
|
+
|
78
|
+
# private object function without leading attribute, no args
|
79
|
+
assert_equal(functions[2].name.name, "bar_priv_default")
|
80
|
+
# private object function without leading attribute, args
|
81
|
+
assert_equal(functions[4].name.name, "test_bar1")
|
82
|
+
|
83
|
+
# with attribute and args
|
84
|
+
assert_equal(functions[1].name.name, "bar_pub1")
|
85
|
+
|
86
|
+
assert_equal(functions[0].fn_type, "obj")
|
87
|
+
assert_equal(functions[7].fn_type, "normal")
|
70
88
|
|
71
89
|
obj_vars = tree.all(:ObjVar)
|
72
90
|
assert_equal(2, obj_vars.length)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nasl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mak Kolybabi
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-06-
|
13
|
+
date: 2018-06-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: racc
|