Skip to content
This repository has been archived by the owner on Jan 10, 2022. It is now read-only.

Commit

Permalink
#3 Fix wrong stream length bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Gallimathias committed Jan 9, 2018
1 parent 839fd66 commit dcf6c4e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
7 changes: 4 additions & 3 deletions Arrow.Core/Parsing/Definition/ScopeSyntax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public override bool TryParse(SyntaxStream stream, Scanner scanner)
}
else
{
Members.AddRange(SearchMember(1, i, stream, scanner));
Members.AddRange(SearchMember(1, i, stream, scanner));
}


Expand All @@ -75,12 +75,13 @@ private IEnumerable<Syntax> SearchMember(int start, int end, SyntaxStream stream
{
int index = start;

while(scanner.TryScan(stream.Skip(index),out Syntax member))
//TODO:Skip to Get
while (index < end && scanner.TryScan(stream.Get(index, end - index), out Syntax member))
{
index += member.Length;
yield return member;

if(index > end)
if (index > end)
{
break;
}
Expand Down
6 changes: 3 additions & 3 deletions Arrow.Core/Parsing/Definition/StatmentSyntax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public override bool TryParse(SyntaxStream stream, Scanner scanner)

for (int i = 0; i < stream.Count; i++)
{
if(stream[i].Name == "CodeLineEnd")
if (stream[i].Name == "CodeLineEnd")
{
Statments.Add(scanner.Scan(stream.Get(lastPosition,i-lastPosition)));
lastPosition = i +1 ;
Statments.Add(scanner.Scan(stream.Get(lastPosition, i - lastPosition)));
lastPosition = i + 1;
result = true;
}
}
Expand Down
3 changes: 3 additions & 0 deletions Arrow.Core/Parsing/SyntaxStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public SyntaxStream(IEnumerable<Token> tokenList)
}
private SyntaxStream(SyntaxStream syntaxStream, int index, int length)
{
if (index + length > syntaxStream.Count)
throw new ArgumentOutOfRangeException(nameof(length));

baseStream = syntaxStream;
this.index = index;
this.length = length;
Expand Down

0 comments on commit dcf6c4e

Please sign in to comment.