Skip to content

Commit a797188

Browse files
authored
Merge pull request #27 from solidity-parser/fix-pragma-values
Join version constraints with a space
2 parents 013764c + 3174bc3 commit a797188

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

.travis.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
language: node_js
22
node_js:
3-
- "8"
3+
- "10"
4+
5+
script:
6+
- npm run eslint
7+
- npm test

src/ASTBuilder.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,16 @@ const transformAST = {
108108
},
109109

110110
PragmaDirective(ctx) {
111+
// this converts something like >= 0.5.0 <0.7.0
112+
// in >=0.5.0 <0.7.0
113+
const value = ctx
114+
.pragmaValue()
115+
.children[0].children.map(x => toText(x))
116+
.join(" ")
117+
111118
return {
112119
name: toText(ctx.pragmaName()),
113-
value: toText(ctx.pragmaValue())
120+
value
114121
}
115122
},
116123

test/ast.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ describe('AST', () => {
7979
"~0.3.11",, "~1.3", "~10",
8080
"=0.0.1", "=0.6", "=1",
8181
"<=1.1.1", "<=11.11", "<=111",
82-
"<0.5.11"]
82+
"<0.5.11", ">=0.6.7 <0.7.0"]
8383
versions.forEach(function (version) {
8484
it("PragmaDirective " + version, function() {
8585
var ast = parser.parse("pragma solidity " + version + ";")

0 commit comments

Comments
 (0)