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

Define Syntax for Iterator Definition #154

Open
7 tasks
kindlich opened this issue Jun 8, 2024 · 0 comments
Open
7 tasks

Define Syntax for Iterator Definition #154

kindlich opened this issue Jun 8, 2024 · 0 comments
Labels
bug Something isn't working documentation Improvements or additions to documentation parser
Milestone

Comments

@kindlich
Copy link
Member

kindlich commented Jun 8, 2024

Currently, StdLib's Iterable.zs defines the Iterator-Member like so:

for(item as T) as Iterator<T> => iterate();

However, the parser expects:

for(T) {
    // What to do in here?
}

Defined in ParsedDefinitionMember:

			case K_FOR: {
				tokens.next();

				tokens.required(T_BROPEN, "( expected");

				List<IParsedType> loopVariableTypes = new ArrayList<>();
				if (tokens.optional(T_BRCLOSE) == null) {
					do {
						loopVariableTypes.add(IParsedType.parse(tokens));
					} while (tokens.optional(T_COMMA) != null);
					tokens.required(T_BRCLOSE, ") expected");
				}

				ParsedFunctionBody body = ParsedStatement.parseFunctionBody(tokens);
				return new ParsedIterator(start, modifiers, annotations, loopVariableTypes, body);
			}

We need to define how the iterator members should look like and how it should behave.

Acceptance Criteria:

  • The syntax is defined
  • The header in stdlibs is adapted to whatever syntax we adopt
  • There exist tests that cover the basic iterator functionality
    • Defining an iterator
    • Calling it
    • Overloading iterators with multiple variables
    • Doing that on a generic data type like List
@kindlich kindlich added bug Something isn't working documentation Improvements or additions to documentation parser labels Jun 8, 2024
@kindlich kindlich added this to the v1.0.0 milestone Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation parser
Projects
None yet
Development

No branches or pull requests

1 participant