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

crucible-syntax: Hooks for parsing top-level forms, custom parser state #1124

Open
langston-barrett opened this issue Nov 8, 2023 · 0 comments
Labels

Comments

@langston-barrett
Copy link
Contributor

The crucible-syntax parser is extensible; the ParserHooks type allows clients to define custom parsers that are applied in type and statement positions. However, language extensions may additionally want to add new top-level forms. Consider the case of Crucible-LLVM, where we might wish to add:

  • LLVM global variables (to be contrasted with Crucible global variables)
  • LLVM declarations (that use LLVM types), to be resolved into common overrides such as malloc, free, memcpy, etc.
  • LLVM metadata (if we ever want to have accurate round-tripping of parsed LLVM modules through this syntax)

These data don't fit nicely into the ParsedProgram nor SyntaxState types (the latter is the state of the TopParser monad). One option would be to add an additional type parameter (sext) to ParsedProgram, and SyntaxState, where both would gain a field of that type that could be modified by the top-level form parser extension. The parser extension could then stash whatever data it wants in there (e.g., LLVM declarations from the llvm-pretty package).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant