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

Parser analysis and errors for labelled statements, break, continue, return #215

Merged
merged 8 commits into from
Jul 25, 2014

Conversation

JsonFreeman
Copy link
Contributor

This pull request covers a couple of things:

  1. Make sure break, continue, return statements are nested in the right control context
  2. Keeping track of labels and making sure jump targets are correct.
  3. Checking for duplicate labels

I've added a state machine to track labelled statements. It has a current label set for the labels being accumulated, as well as a stack for label sets of enclosing statements. It also tracks whether the enclosing labelled statements are iteration statements or not, because continue statements can only jump to iteration statements.


Debug.assert(inIterationStatement === ControlBlockContext.CrossingFunctionBoundary
|| inSwitchStatement === ControlBlockContext.CrossingFunctionBoundary);
grammarErrorAtPos(errorStart, errorLength, Diagnostics.Jump_target_cannot_cross_function_boundary);
Copy link
Contributor

Choose a reason for hiding this comment

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

i'd honestly prefer this was just repeated and htere was no fallthrough above. but up to you.

return ControlBlockContext.NotNested;
}

// TODO(jfreeman): Fill in these stubs
Copy link
Member

Choose a reason for hiding this comment

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

Remember to get rid of this now.

@DanielRosenwasser
Copy link
Member

👍 after feedback is addressed.

Conflicts:
	src/compiler/diagnosticInformationMap.generated.ts
	src/compiler/diagnosticMessages.json
	src/compiler/parser.ts
JsonFreeman added a commit that referenced this pull request Jul 25, 2014
Parser analysis and errors for labelled statements, break, continue, return
@JsonFreeman JsonFreeman merged commit cb98c5a into master Jul 25, 2014
@JsonFreeman JsonFreeman deleted the labelledStatements branch July 25, 2014 00:52
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants