Skip to content

Commit d4c6a86

Browse files
authored
Merge pull request #103 from solidity-parser/ditching_antlr4ts
Ditching antlr4ts
2 parents 42ba32e + 54116a8 commit d4c6a86

22 files changed

+4436
-5202
lines changed

.eslintignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
src/lib
22
src/antlr
3-
scripts/tokens-string.js
3+
scripts

.github/workflows/CI.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ jobs:
3838
cache: 'npm'
3939
- name: Install
4040
run: npm install
41+
- name: Install ANTLR4
42+
run: pip install antlr4-tools
4143
- name: Build
4244
run: npm run build
4345
- name: Run integration

CHANGES.md renamed to CHANGELOG.md

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,81 @@
1-
### 0.5.0 (Unreleased)
1+
# 0.17.0
2+
3+
- Using the official typescript target for antlr4. (#103)
4+
- Exponentiation is right associative. `a ** (b ** c)` (#99)
5+
- Conditional expression is right associative. `a ? (b ? c : d) : (e ? f : g)` (#99)
6+
7+
# 0.5.0
28

39
- Remove `ParameterList` and `Parameter` node types. Parameters are now always
410
of type `VariableDeclaration` and lists of parameters are represented as
511
lists of nodes of type `VariableDeclaration`. This is a breaking change.
612

7-
### 0.4.12 (Unreleased)
13+
# 0.4.12
814

915
- Fix type name expressions to also support user-defined type names.
1016

11-
### 0.4.11
17+
# 0.4.11
1218

1319
- Bugfix release
1420

15-
### 0.4.9
21+
# 0.4.9
1622

1723
- Fix parsing of inheritance specifier with no arguments.
1824

19-
### 0.4.8
25+
# 0.4.8
2026

2127
- Fix parsing of string literals with escaped characters.
2228

23-
### 0.4.7
29+
# 0.4.7
2430

2531
- Fix parsing of underscores in number literals.
2632

27-
### 0.4.6
33+
# 0.4.6
2834

2935
- Add support for the `type` keyword.
3036
- Add support for underscores in number literals.
3137

32-
### 0.4.5
38+
# 0.4.5
3339

3440
- Improve TypeScript type definitions.
3541

36-
### 0.4.4
42+
# 0.4.4
3743

3844
- Add missing `storageLocation` to variables in VariableDeclarationStatement.
3945
- Return `null` for `arguments` instead of `[]` when `ModifierInvocation`
4046
contains no arguments and no parentheses to distinguish the two cases.
4147
- Improve TypeScript type definitions.
4248

43-
### 0.4.3
49+
# 0.4.3
4450

4551
- Improve TypeScript type definitions, thanks @Leeleo3x and @yxliang01.
4652

47-
### 0.4.2
53+
# 0.4.2
4854

4955
- Fix parsing of assembly function definitions with no args or return args.
5056

51-
### 0.4.1
57+
# 0.4.1
5258

5359
- Fix parsing of for loops with missing initial and condition statements.
5460

55-
### 0.4.0
61+
# 0.4.0
5662

5763
- Correctly handle non-existent tuple components. Thanks @maxsam4
5864
- Accept calldata as identifier
5965

60-
### 0.3.3
66+
# 0.3.3
6167

6268
- Add support for `address payable` typename.
6369

64-
### 0.3.2
70+
# 0.3.2
6571

6672
- Fix parsing of hex numbers with uppercase X.
6773

68-
### 0.3.1
74+
# 0.3.1
6975

7076
- Fix parsing of zero-component tuples.
7177

72-
### 0.3.0
78+
# 0.3.0
7379

7480
- Use `components` for all `TupleExpression` nodes. Earlier versions
7581
incorrectly stored tuple components under the `elements` key.

DEVELOPING.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,33 @@ git submodule update --init
2727

2828
## Updating the grammar
2929

30-
The [`scripts/antlr.sh`](scripts/antlr.sh) script should download ANTLR and generate the grammar. For this to work, you
31-
need Java (1.6 or higher) installed.
30+
If you want to try changes made to the `antlr/Solidity.g4` file you need to generate the typescript files to reflect the changes.
31+
32+
To accomplish that, we rely on [antlr4-tools](https://github.com/antlr/antlr4-tools) to generate the grammar.
33+
34+
```bash
35+
# it requires Python 3 but doesn't require Java.
36+
# install antlr4-tools
37+
pip install antlr4-tools
38+
```
39+
40+
Once it is installed you just need to run the following `npm` script to generate the new grammar files.
41+
42+
```bash
43+
# generate the grammar Typescript files
44+
npm run antlr
45+
```
3246

3347
## Updating the parser
3448

35-
Run `yarn build` to build the parser.
49+
Run `npm run build` to build the parser.
3650

3751
## Quick testing
3852

3953
Right now the easier way to test something is to start the node REPL and import the project:
4054

4155
```
42-
yarn build
56+
npm run build
4357
node
4458
> parser = require('.')
4559
> ast = parser.parse('contract Foo {}')

0 commit comments

Comments
 (0)