Skip to content

Commit

Permalink
Merge remote-tracking branch 'paweljasinski/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhardy committed May 15, 2012
2 parents 2e22007 + f8d01c4 commit 8446d8b
Show file tree
Hide file tree
Showing 3 changed files with 1,384 additions and 84 deletions.
38 changes: 32 additions & 6 deletions Languages/IronPython/IronPython/Compiler/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2734,7 +2734,7 @@ private Expression FinishDictOrSetValue() {
if (!first) {
ReportSyntaxError("invalid syntax");
}
return FinishDictComp(e1, e2);
return FinishDictComp(e1, e2, oStart, oEnd);
}

SliceExpression se = new SliceExpression(e1, e2, null, false);
Expand All @@ -2752,7 +2752,7 @@ private Expression FinishDictOrSetValue() {
if (!first) {
ReportSyntaxError("invalid syntax");
}
return FinishSetComp(e1);
return FinishSetComp(e1, oStart, oEnd);
}

// error recovery
Expand Down Expand Up @@ -2800,17 +2800,43 @@ private Expression FinishDictOrSetValue() {
}

// comp_iter '}'
private SetComprehension FinishSetComp(Expression item) {
private SetComprehension FinishSetComp(Expression item, int oStart, int oEnd) {
ComprehensionIterator[] iters = ParseCompIter();
Eat(TokenKind.RightBrace);
return new SetComprehension(item, iters);

var cStart = GetStart();
var cEnd = GetEnd();
if (_sink != null) {
_sink.MatchPair(
new SourceSpan(_tokenizer.IndexToLocation(oStart), _tokenizer.IndexToLocation(oEnd)),
new SourceSpan(_tokenizer.IndexToLocation(cStart), _tokenizer.IndexToLocation(cEnd)),
1
);
}

var ret = new SetComprehension(item, iters);
ret.SetLoc(_globalParent, oStart, cEnd);
return ret;
}

// comp_iter '}'
private DictionaryComprehension FinishDictComp(Expression key, Expression value) {
private DictionaryComprehension FinishDictComp(Expression key, Expression value, int oStart, int oEnd) {
ComprehensionIterator[] iters = ParseCompIter();
Eat(TokenKind.RightBrace);
return new DictionaryComprehension(key, value, iters);

var cStart = GetStart();
var cEnd = GetEnd();

if (_sink != null) {
_sink.MatchPair(
new SourceSpan(_tokenizer.IndexToLocation(oStart), _tokenizer.IndexToLocation(oEnd)),
new SourceSpan(_tokenizer.IndexToLocation(cStart), _tokenizer.IndexToLocation(cEnd)),
1
);
}
var ret = new DictionaryComprehension(key, value, iters);
ret.SetLoc(_globalParent, oStart, cEnd);
return ret;
}

// comp_iter: comp_for | comp_if
Expand Down
Loading

0 comments on commit 8446d8b

Please sign in to comment.