Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add C# support to Canopy. #2

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a6bb9cb
init cs support
ElDuderinos May 11, 2023
24f00b1
now it actually outputs valid cs code
ElDuderinos May 11, 2023
aaf7aa8
remove log
ElDuderinos May 11, 2023
ce602c3
makefile cs
ElDuderinos May 11, 2023
1c27300
moving forward with tests
ElDuderinos May 11, 2023
b7412ad
choices tests are compiling!
ElDuderinos May 11, 2023
20a967c
more tests fixes
ElDuderinos May 12, 2023
010982c
tests are running
ElDuderinos May 12, 2023
dea3346
fixed null getter and substring
ElDuderinos May 12, 2023
0a74744
choices tests are passing!!!
ElDuderinos May 12, 2023
07e4b2a
fixed regex and also node actions are passing
ElDuderinos May 12, 2023
90e97e3
predicates test
ElDuderinos May 12, 2023
2d1e9db
quantifiers test
ElDuderinos May 12, 2023
39c17ab
sequencs test
ElDuderinos May 12, 2023
0053bd3
makefile sequencs test
ElDuderinos May 12, 2023
77c60d7
terminals test and handle many warnings and null stuff
ElDuderinos May 12, 2023
148c913
cs github actions
ElDuderinos May 12, 2023
0b6c911
added namespace
ElDuderinos May 13, 2023
5215295
add cs docs
ElDuderinos May 13, 2023
f0bca8f
debug cs actions
ElDuderinos May 13, 2023
41e7fb0
sync tests with namespace
ElDuderinos May 13, 2023
8258fdb
cleanup and better support of other runtimes
ElDuderinos May 13, 2023
c6f9ec2
try github actions env var map matrix
ElDuderinos May 13, 2023
43770d9
break tests
ElDuderinos May 13, 2023
2293b6b
fix env var
ElDuderinos May 13, 2023
dac4fe3
updated frameworks
ElDuderinos May 13, 2023
530a78f
more versions
ElDuderinos May 13, 2023
1ef8772
remove nullable directive for better legacy support
ElDuderinos May 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions .github/workflows/cs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
on:
- push
- pull_request

jobs:
test-dotnet21:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Setup .NET Core SDK 2.1.x
uses: actions/setup-dotnet@v3
with:
dotnet-version: '2.1.x'
- name: Run test 2.1.x
run: make test-cs
env:
DOTNET_SDK: netcoreapp2.1
test-dotnet22:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Setup .NET Core SDK 2.2.x
uses: actions/setup-dotnet@v3
with:
dotnet-version: '2.2.x'
- name: Run test 2.2.x
run: make test-cs
env:
DOTNET_SDK: netcoreapp2.2
test-dotnet30:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Setup .NET Core SDK 3.0.x
uses: actions/setup-dotnet@v3
with:
dotnet-version: '3.0.x'
- name: Run test 3.0.x
run: make test-cs
env:
DOTNET_SDK: netcoreapp3.0
test-dotnet31:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Setup .NET Core SDK 3.1.x
uses: actions/setup-dotnet@v3
with:
dotnet-version: '3.1.x'
- name: Run test 3.1.x
run: make test-cs
env:
DOTNET_SDK: netcoreapp3.1
test-dotnet50:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Setup .NET Core SDK 5.0.x
uses: actions/setup-dotnet@v3
with:
dotnet-version: '5.0.x'
- name: Run test 5.0.x
run: make test-cs
env:
DOTNET_SDK: net5.0
test-dotnet60:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Setup .NET Core SDK 6.0.x
uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.0.x'
- name: Run test 6.0.x
run: make test-cs
env:
DOTNET_SDK: net6.0


12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ test/%.js: test/%.peg $(lib_files)
%/Grammar.java: %.peg $(lib_files)
./bin/canopy --lang java $<

%/Grammar.cs: %.peg $(lib_files)
./bin/canopy --lang cs $<

%.py: %.peg $(lib_files)
./bin/canopy --lang python $<

Expand All @@ -50,6 +53,15 @@ test-all: test-java test-js test-python test-ruby
test-java: $(test_grammars:%.peg=%/Grammar.java)
cd test/java && mvn clean test

DOTNET_SDK?=netcoreapp3.1
test-cs: $(test_grammars:%.peg=%/Grammar.cs)
cd test/cs/choices && dotnet test --framework ${DOTNET_SDK}
cd test/cs/node_actions && dotnet test --framework ${DOTNET_SDK}
cd test/cs/predicates && dotnet test --framework ${DOTNET_SDK}
cd test/cs/quantifiers && dotnet test --framework ${DOTNET_SDK}
cd test/cs/sequences && dotnet test --framework ${DOTNET_SDK}
cd test/cs/terminals && dotnet test --framework ${DOTNET_SDK}

test-js: test/javascript/node_modules $(test_grammars:%.peg=%.js)
cd test/javascript && npm test

Expand Down
62 changes: 41 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,42 @@
{ "name" : "canopy"
, "description" : "PEG parser compiler for JavaScript"
, "homepage" : "https://canopy.jcoglan.com"
, "author" : "James Coglan <[email protected]> (http://jcoglan.com/)"
, "keywords" : ["parser", "compiler", "peg"]
, "license" : "MPL-2.0"

, "version" : "0.4.0"
, "engines" : { "node": ">=8.0.0" }
, "files" : ["bin", "lib", "templates"]
, "main" : "./lib/canopy.js"
, "bin" : { "canopy": "./bin/canopy" }

, "dependencies" : { "handlebars": ">=4.0.0", "mkdirp": ">=3.0.0", "nopt": "*" }
, "devDependencies" : { "benchmark": "", "jstest": "", "pegjs": "" }

, "bugs" : { "url": "https://github.com/jcoglan/canopy/issues" }

, "repository" : { "type" : "git"
, "url" : "git://github.com/jcoglan/canopy.git"
}
{
"name": "canopy",
"description": "PEG parser compiler for JavaScript",
"homepage": "https://canopy.jcoglan.com",
"author": "James Coglan <[email protected]> (http://jcoglan.com/)",
"keywords": [
"parser",
"compiler",
"peg"
],
"license": "MPL-2.0",
"version": "0.4.0",
"engines": {
"node": ">=8.0.0"
},
"files": [
"bin",
"lib",
"templates"
],
"main": "./lib/canopy.js",
"bin": {
"canopy": "./bin/canopy"
},
"dependencies": {
"handlebars": ">=4.0.0",
"mkdirp": ">=3.0.0",
"nopt": "*"
},
"devDependencies": {
"benchmark": "",
"jstest": "",
"pegjs": ""
},
"bugs": {
"url": "https://github.com/jcoglan/canopy/issues"
},
"repository": {
"type": "git",
"url": "git://github.com/jcoglan/canopy.git"
}
}
2 changes: 2 additions & 0 deletions site/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ Canopy can generate parsers in the following languages:
* [JavaScript](/langs/javascript.html)
* [Python](/langs/python.html)
* [Ruby](/langs/ruby.html)
* [.Net](/langs/cs.html)

Loading