Skip to content

Conversation

@wpbonelli
Copy link
Member

@wpbonelli wpbonelli commented Jul 23, 2025

more progress on lark parser. demonstrate how generated component-specific grammars can build on a typed base grammar knowing about the various input formats (readarray, etc)

def arrays_vars(self, items: list[Any]) -> dict:
return {item[0].lower(): item[1] for item in items}

def r2d2(self, _: list[Any]) -> bool:
Copy link
Member Author

@wpbonelli wpbonelli Jul 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of hardcoding these in future, we can inject component class definitions into the transformer, and have a single hook which handles blocks, variables, etc as appropriate based on the class definition

grammar = """
start: block*
block: options_block | arrays_block
options_block: "begin"i "options"i options_vars "end"i "options"i
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grammars like these, aware of the names/contents of blocks, and the names/types of variables, can be generated for each component

@wpbonelli wpbonelli marked this pull request as ready for review July 23, 2025 20:21
@wpbonelli wpbonelli merged commit faf27ea into modflowpy:develop Jul 23, 2025
11 checks passed
@wpbonelli wpbonelli deleted the larking branch July 29, 2025 19:20
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.

1 participant