Skip to content

Commit

Permalink
Merge pull request #2 from yannickbattail/fix-empty-vector-bug
Browse files Browse the repository at this point in the history
Fix empty vector bug
  • Loading branch information
hugheaves authored Dec 18, 2023
2 parents 2cf85db + e4f2aaa commit 9e68f7e
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 20 deletions.
65 changes: 46 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,57 @@ SCADFormat is written in Go, and uses the ANTLR v4 parser generator. You'll need

See https://go.dev/doc/install to install Go (v1.21 or later) and https://github.com/antlr/antlr4/blob/master/doc/getting-started.md to install ANTLR.

```bash
python3 -m venv venv
. ./venv/bin/activate
pip install antlr4-tools
```

After installation, run the "antlr4" command to verify the command is available in your search path:

$ antlr4
ANTLR Parser Generator Version 4.13.1
-o ___ specify output directory where all output is generated
-lib ___ specify location of grammars, tokens files
-atn generate rule augmented transition network diagrams
...
```bash
antlr4
```
should display
```
ANTLR Parser Generator Version 4.13.1
-o ___ specify output directory where all output is generated
-lib ___ specify location of grammars, tokens files
-atn generate rule augmented transition network diagrams
...
```


### Checkout And Build

Once ANTLR and Go are installed, the SCADFormat can be built as follows:

# Checkout source code
git clone https:;//github.com/hugheaves/scadformat

# Go into the respository
cd scadformat

# Generate ANTLR parser
go generate ./...

# Build the executable
go build -o scadformat cmd/main.go


Checkout source code
```bash
git clone https:;//github.com/hugheaves/scadformat
```

Go into the respository
```bash
cd scadformat
```

Generate ANTLR parser
```bash
go generate ./...
```

Build the executable
```bash
go build -o scadformat cmd/main.go
```

run tests
```bash
go test -v ./...
```

run on a file
```bash
./scadformat ./internal/formatter/testdata/solo_adapter.scad
```
2 changes: 2 additions & 0 deletions internal/formatter/testdata/empty_vector_bug.scad
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
a=x?[]:[ ];
b =[] ;
2 changes: 2 additions & 0 deletions internal/formatter/testdata/empty_vector_bug.scad.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
a = x ? [] : [];
b = [];
2 changes: 1 addition & 1 deletion internal/parser/OpenSCAD.g4
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ parenthetical

vector
:
L_BRACKET vectorArguments R_BRACKET
L_BRACKET vectorArguments? R_BRACKET
;

vectorArguments
Expand Down

0 comments on commit 9e68f7e

Please sign in to comment.