Skip to content

Implement control flow #3

@gregschmit

Description

@gregschmit

Ultimately, I want to support all BSD and GNU variants. BSD variants all seem to start with a period (e.g., .if, .for), so that means there shouldn't be any conflicts.

We can't get around this with a preprocessor because the conditionals and loops will depend on variable state, so this needs to be baked into the normal parser. This can probably be done similar to how variable expansion is done: by having vector of Frame structs which will behave as a stack and when we come across control flow statements, we just need to push to or pop from the stack, and when popping, evaluate the inner portion properly (for conditionals we just decide to parse the inner or not, and with loops we execute the inner however many times we need, resetting the line number state and handling the variable assignments properly).

The only thing that concerns me is nested control flow, where we almost have to evaluate temporarily because there could be a wrapping conditional that ignores everything, or a wrapping for that iterates everything.

So this is probably going to be a headache.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions