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

ACSetSpec PEG.jl-based Implemenation #153

Merged
merged 20 commits into from
Oct 8, 2024

Conversation

cscaff
Copy link
Contributor

@cscaff cscaff commented Oct 2, 2024

The following PR contains two main files: src/parsers.jl as well as test/parsers.jl. This contains a module for constructing a parse expression grammar for creating an ADT representation from an ACSet specification. The use of PEG.jl allows us to build ASTs that are not constrained to the way Julia treats code as data. We can define our expressions in our tree the way we see fit. I have also included a testing module to ensure that the parser functions properly. The new parser can be called by a string macro: "acsetspec_str". For instance, we can call:

acsetspec"""
    LabeledGraph{Symbol}
    begin
      V(label=a)
      V(label=b)
      V(label=c)
      E(src=1,tgt=3)
      E(src=2,tgt=3)
    end"""

@lukem12345
Copy link
Member

I noticed that the function parse_identifier happened to always be passed Chars, so I devised a test for the case in which an identifier is more than one character.

This test fails:

@test args("foo, b ,c")[1] == ([Value(:foo), Value(:b), Value(:c)])

The LHS evaluates to ACSets.ADTs.Value{Symbol}[f, b, c].

src/parsers.jl Outdated Show resolved Hide resolved
src/parsers.jl Outdated Show resolved Hide resolved
test/parsers.jl Outdated Show resolved Hide resolved
src/parsers.jl Outdated Show resolved Hide resolved
src/parsers.jl Outdated Show resolved Hide resolved
@lukem12345 lukem12345 requested a review from quffaro October 3, 2024 22:47
Copy link

codecov bot commented Oct 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.72%. Comparing base (0c5b066) to head (aaaed94).
Report is 21 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #153      +/-   ##
==========================================
- Coverage   92.06%   91.72%   -0.35%     
==========================================
  Files          23       24       +1     
  Lines        2118     2139      +21     
==========================================
+ Hits         1950     1962      +12     
- Misses        168      177       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lukem12345
Copy link
Member

@jpfairbanks It looks like @quffaro and I both approve. Merge?

@jpfairbanks
Copy link
Member

Merge

@jpfairbanks jpfairbanks merged commit 4ea3ec1 into AlgebraicJulia:main Oct 8, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants