Skip to content

Commit

Permalink
Merge pull request #15 from viktordanov/refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
viktordanov authored Sep 13, 2022
2 parents 1eaf78b + 1eaff56 commit b6a75b6
Show file tree
Hide file tree
Showing 25 changed files with 2,347 additions and 5,069 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/github-actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- run: echo "Testing Abacus"
- run: echo "Running tests"
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
- uses: actions/setup-go@v3
with:
go-version: '>=1.18.0'
- name: Run tests
run: go test -v -covermode=atomic -race ./...
build-and-release:
Expand All @@ -16,12 +18,14 @@ jobs:
steps:
- run: echo "Building Abacus"
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
- uses: actions/setup-go@v3
with:
go-version: '>=1.18.0'
- name: Build step
run: |
GOOS=windows GOARCH=amd64 go build -o abacus-windows-amd64.exe
GOOS=linux GOARCH=amd64 go build -o abacus-linux-amd64
GOOS=darwin GOARCH=amd64 go build -o abacus-macos-amd64
GOOS=windows GOARCH=amd64 go build -o abacus-windows-amd64.exe ./cmd/abacus-cli
GOOS=linux GOARCH=amd64 go build -o abacus-linux-amd64 ./cmd/abacus-cli
GOOS=darwin GOARCH=amd64 go build -o abacus-macos-amd64 ./cmd/abacus-cli
- name: Set version tag
run: echo "VERSION_TAG=$(./abacus-linux-amd64 --version)" >> $GITHUB_ENV
- uses: ncipollo/release-action@v1
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
# Dependency directories (remove the comment below to include it)
# vendor/
.idea/
abacus
./abacus
definitions.a
.DS_Store
55 changes: 31 additions & 24 deletions Abacus.g4
Original file line number Diff line number Diff line change
Expand Up @@ -108,31 +108,36 @@ sign
| '-' # MinusSign;


//function
// : 'sqrt' LPAREN expression RPAREN # SqrtFunction
// | 'cbrt' LPAREN expression RPAREN # CbrtFunction
// | 'ln' LPAREN expression RPAREN # LnFunction
// | 'log' LPAREN expression RPAREN # LogDefFunction
// | 'log2' LPAREN expression RPAREN # Log2Function
// | 'log10' LPAREN expression RPAREN # Log10Function
// | 'floor' LPAREN expression RPAREN # FloorFunction
// | 'ceil' LPAREN expression RPAREN # CeilFunction
// | 'exp' LPAREN expression RPAREN # ExpFunction
// | 'sin' LPAREN expression RPAREN # SinFunction
// | 'cos' LPAREN expression RPAREN # CosFunction
// | 'tan' LPAREN expression RPAREN # TanFunction
// | 'round' LPAREN expression RPAREN # RoundDefFunction
// | 'sign' LPAREN expression RPAREN # SignFunction
// | 'abs' LPAREN expression RPAREN # AbsFunction
// | 'round' LPAREN expression ',' expression RPAREN # Round2Function
// | 'log' LPAREN expression ',' expression RPAREN # LogFunction
// | 'min' LPAREN tuple RPAREN # MinFunction
// | 'max' LPAREN tuple RPAREN # MaxFunction
// | 'avg' LPAREN tuple RPAREN # AvgFunction
// | 'until' LPAREN tuple ',' expression RPAREN # UntilFunction
// | 'from' LPAREN tuple RPAREN # FromFunction
// | 'reverse' LPAREN tuple RPAREN # ReverseFunction
// | 'nth' LPAREN tuple ',' expression RPAREN # NthFunction
// ;


function
: 'sqrt' LPAREN expression RPAREN # SqrtFunction
| 'cbrt' LPAREN expression RPAREN # CbrtFunction
| 'ln' LPAREN expression RPAREN # LnFunction
| 'log' LPAREN expression RPAREN # LogDefFunction
| 'log2' LPAREN expression RPAREN # Log2Function
| 'log10' LPAREN expression RPAREN # Log10Function
| 'floor' LPAREN expression RPAREN # FloorFunction
| 'ceil' LPAREN expression RPAREN # CeilFunction
| 'exp' LPAREN expression RPAREN # ExpFunction
| 'sin' LPAREN expression RPAREN # SinFunction
| 'cos' LPAREN expression RPAREN # CosFunction
| 'tan' LPAREN expression RPAREN # TanFunction
| 'round' LPAREN expression RPAREN # RoundDefFunction
| 'sign' LPAREN expression RPAREN # SignFunction
| 'abs' LPAREN expression RPAREN # AbsFunction
| 'round' LPAREN expression ',' expression RPAREN # Round2Function
| 'log' LPAREN expression ',' expression RPAREN # LogFunction
| 'min' LPAREN tuple RPAREN # MinFunction
| 'max' LPAREN tuple RPAREN # MaxFunction
| 'avg' LPAREN tuple RPAREN # AvgFunction
| 'until' LPAREN tuple ',' expression RPAREN # UntilFunction
| 'from' LPAREN tuple RPAREN # FromFunction
| 'reverse' LPAREN tuple RPAREN # ReverseFunction
| 'nth' LPAREN tuple ',' expression RPAREN # NthFunction
: VARIABLE LPAREN tuple RPAREN # FunctionInvocation
;


Expand All @@ -151,10 +156,12 @@ fragment NUMBER
: DIGITS+ (POINT DIGITS +)?
;


VARIABLE
: VALID_ID_START VALID_ID_CHAR*
;


LAMBDA_VARIABLE
: UPPERCASE VALID_ID_CHAR*
;
Expand Down
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
BIN = abacus
BIN=abacus

all: compile run

test:
go test -v -covermode=atomic -race ./...

compile:
go build -o $(BIN)
go build -o $(BIN) ./cmd/abacus-cli/main.go

recompile-grammar:
antlr4 -Dlanguage=Go -o parser/ Abacus.g4 -visitor

run:
./$(BIN)
Loading

0 comments on commit b6a75b6

Please sign in to comment.