solidity 0.1.3 → 0.1.4
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/README.md +30 -1
- data/lib/solidity/parser.rb +46 -2
- data/lib/solidity/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3920e32ab53156b256507811437d64f62f38bd42472aecb5c51a4fd3eb2f57e1
|
4
|
+
data.tar.gz: 4a5c36c583ba102881417af5d184c6351ef9d6a1f20154ab6096fb4722694bc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7227cdec56deceba0230c0f8946ea0182e2e144919bb2b0227d52a19c4085d89a0b2f3a62c796b162c9fba59880d5ee1cb154bfc0f5de1455cb4bd353d4602d
|
7
|
+
data.tar.gz: 9840c43aade93aaec0b0222c2db7dc4f50246565da9e52c69363fe599e43bed8e0e800ac31349a846ab7cfeb4e28126bde9fcfd8d6a85b884d9d26240b1fc35b
|
data/README.md
CHANGED
@@ -55,7 +55,6 @@ Awesome Solidity @ <https://github.com/bkrem/awesome-solidity>
|
|
55
55
|
## Usage
|
56
56
|
|
57
57
|
Get / generate outline from source in the solidity (`.sol`) contract programming language:
|
58
|
-
|
59
58
|
```ruby
|
60
59
|
[
|
61
60
|
"0x34625ecaa75c0ea33733a05c584f4cf112c10b6b",
|
@@ -92,6 +91,36 @@ library Base64
|
|
92
91
|
```
|
93
92
|
|
94
93
|
|
94
|
+
Note: The outline includes:
|
95
|
+
|
96
|
+
1. contract definitions e.g.
|
97
|
+
|
98
|
+
contract NounsDescriptor is INounsDescriptor, Ownable
|
99
|
+
|
100
|
+
2. abstract contract definitions e.g.
|
101
|
+
|
102
|
+
abstract contract Ownable is Context
|
103
|
+
abstract contract Context
|
104
|
+
|
105
|
+
3. library definitions e.g.
|
106
|
+
|
107
|
+
library Strings
|
108
|
+
library NFTDescriptor
|
109
|
+
library MultiPartRLEToSVG
|
110
|
+
library Base64
|
111
|
+
|
112
|
+
4. interface definitions e.g.
|
113
|
+
|
114
|
+
interface INounsDescriptor
|
115
|
+
interface INounsSeeder
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
<!-- break -->
|
121
|
+
|
122
|
+
More outline samples:
|
123
|
+
|
95
124
|
```
|
96
125
|
outline:
|
97
126
|
contract Indelible is ERC721A, ReentrancyGuard, Ownable
|
data/lib/solidity/parser.rb
CHANGED
@@ -25,6 +25,22 @@ class Parser
|
|
25
25
|
|
26
26
|
## todo/fix - check if [^`] includes/matches newline too (yes)? -- add \n for multi-line!
|
27
27
|
|
28
|
+
|
29
|
+
## from the solidity grammar
|
30
|
+
##
|
31
|
+
## StringLiteralFragment
|
32
|
+
## : 'unicode'? '"' DoubleQuotedStringCharacter* '"'
|
33
|
+
## | 'unicode'? '\'' SingleQuotedStringCharacter* '\'' ;
|
34
|
+
##
|
35
|
+
## fragment
|
36
|
+
## DoubleQuotedStringCharacter
|
37
|
+
## : ~["\r\n\\] | ('\\' .) ;
|
38
|
+
##
|
39
|
+
## fragment
|
40
|
+
## SingleQuotedStringCharacter
|
41
|
+
## : ~['\r\n\\] | ('\\' .) ;
|
42
|
+
|
43
|
+
|
28
44
|
SINGLE_QUOTE = %r{'
|
29
45
|
( \\\\. | [^'] )*
|
30
46
|
'}x
|
@@ -34,7 +50,25 @@ class Parser
|
|
34
50
|
"}x
|
35
51
|
|
36
52
|
|
37
|
-
|
53
|
+
## from the solidity grammar
|
54
|
+
## > An identifier in solidity has to start with a letter,
|
55
|
+
## > a dollar-sign or an underscore and
|
56
|
+
## > may additionally contain numbers after the first symbol.
|
57
|
+
##
|
58
|
+
## Identifier
|
59
|
+
## : IdentifierStart IdentifierPart* ;
|
60
|
+
##
|
61
|
+
## fragment
|
62
|
+
## IdentifierStart
|
63
|
+
## : [a-zA-Z$_] ;
|
64
|
+
##
|
65
|
+
## fragment
|
66
|
+
## IdentifierPart
|
67
|
+
## : [a-zA-Z0-9$_] ;
|
68
|
+
|
69
|
+
NAME = /[a-zA-Z$_][a-zA-Z0-9$_]*/
|
70
|
+
|
71
|
+
|
38
72
|
END_OF_LINE = /\n|$/
|
39
73
|
## inline comments (multi- or end-of-line)
|
40
74
|
END_OF_LINE_OR_COMMENT_OR_KEYWORD_OR_QUOTE = / \n
|
@@ -49,6 +83,16 @@ class Parser
|
|
49
83
|
/x
|
50
84
|
|
51
85
|
|
86
|
+
## from the solidity grammar
|
87
|
+
##
|
88
|
+
## COMMENT
|
89
|
+
## : '/*' .*? '*/' ;
|
90
|
+
##
|
91
|
+
## LINE_COMMENT
|
92
|
+
## : '//' ~[\r\n]* ;
|
93
|
+
|
94
|
+
|
95
|
+
|
52
96
|
def _norm_whitespace( str )
|
53
97
|
## change newlines to spaces and
|
54
98
|
## all multiple spaces to one
|
@@ -106,7 +150,7 @@ class Parser
|
|
106
150
|
## print "abstract contract:"
|
107
151
|
## pp code
|
108
152
|
tree << [:abstract_contract, code]
|
109
|
-
|
153
|
+
when 'library'
|
110
154
|
code = s.scan_until( /(?=\{)/ )
|
111
155
|
code = _norm_whitespace( code )
|
112
156
|
## print "library:"
|
data/lib/solidity/version.rb
CHANGED