Skip to content

Commit

Permalink
Merge pull request #103 from solidity-parser/ditching_antlr4ts
Browse files Browse the repository at this point in the history
Ditching antlr4ts
  • Loading branch information
fvictorio authored Dec 21, 2023
2 parents 42ba32e + 54116a8 commit d4c6a86
Show file tree
Hide file tree
Showing 22 changed files with 4,436 additions and 5,202 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
src/lib
src/antlr
scripts/tokens-string.js
scripts
2 changes: 2 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ jobs:
cache: 'npm'
- name: Install
run: npm install
- name: Install ANTLR4
run: pip install antlr4-tools
- name: Build
run: npm run build
- name: Run integration
Expand Down
40 changes: 23 additions & 17 deletions CHANGES.md → CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,75 +1,81 @@
### 0.5.0 (Unreleased)
# 0.17.0

- Using the official typescript target for antlr4. (#103)
- Exponentiation is right associative. `a ** (b ** c)` (#99)
- Conditional expression is right associative. `a ? (b ? c : d) : (e ? f : g)` (#99)

# 0.5.0

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

### 0.4.12 (Unreleased)
# 0.4.12

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

### 0.4.11
# 0.4.11

- Bugfix release

### 0.4.9
# 0.4.9

- Fix parsing of inheritance specifier with no arguments.

### 0.4.8
# 0.4.8

- Fix parsing of string literals with escaped characters.

### 0.4.7
# 0.4.7

- Fix parsing of underscores in number literals.

### 0.4.6
# 0.4.6

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

### 0.4.5
# 0.4.5

- Improve TypeScript type definitions.

### 0.4.4
# 0.4.4

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

### 0.4.3
# 0.4.3

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

### 0.4.2
# 0.4.2

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

### 0.4.1
# 0.4.1

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

### 0.4.0
# 0.4.0

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

### 0.3.3
# 0.3.3

- Add support for `address payable` typename.

### 0.3.2
# 0.3.2

- Fix parsing of hex numbers with uppercase X.

### 0.3.1
# 0.3.1

- Fix parsing of zero-component tuples.

### 0.3.0
# 0.3.0

- Use `components` for all `TupleExpression` nodes. Earlier versions
incorrectly stored tuple components under the `elements` key.
Expand Down
22 changes: 18 additions & 4 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,33 @@ git submodule update --init

## Updating the grammar

The [`scripts/antlr.sh`](scripts/antlr.sh) script should download ANTLR and generate the grammar. For this to work, you
need Java (1.6 or higher) installed.
If you want to try changes made to the `antlr/Solidity.g4` file you need to generate the typescript files to reflect the changes.

To accomplish that, we rely on [antlr4-tools](https://github.com/antlr/antlr4-tools) to generate the grammar.

```bash
# it requires Python 3 but doesn't require Java.
# install antlr4-tools
pip install antlr4-tools
```

Once it is installed you just need to run the following `npm` script to generate the new grammar files.

```bash
# generate the grammar Typescript files
npm run antlr
```

## Updating the parser

Run `yarn build` to build the parser.
Run `npm run build` to build the parser.

## Quick testing

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

```
yarn build
npm run build
node
> parser = require('.')
> ast = parser.parse('contract Foo {}')
Expand Down
Loading

0 comments on commit d4c6a86

Please sign in to comment.