-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Continued work on expression parsing, added operator expression parsi…
…ng and argument list parsing. #6
- Loading branch information
1 parent
ef0be6c
commit 9886117
Showing
27 changed files
with
1,201 additions
and
372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
TSQL_Parser/TSQL_Parser/Expressions/Parsers/TSQLArgumentListParser.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
using TSQL.Tokens; | ||
|
||
namespace TSQL.Expressions.Parsers | ||
{ | ||
internal class TSQLArgumentListParser | ||
{ | ||
public TSQLArgumentList Parse(ITSQLTokenizer tokenizer) | ||
{ | ||
List<TSQLExpression> arguments = new List<TSQLExpression>(); | ||
|
||
TSQLExpressionFactory factory = new TSQLExpressionFactory(); | ||
|
||
List<TSQLToken> tokens = new List<TSQLToken>(); | ||
|
||
// need to do this before starting the argument loop | ||
// so we can handle an empty argument list of just whitespace | ||
// and comments | ||
while ( | ||
tokenizer.Current != null && | ||
( | ||
tokenizer.Current.IsComment() || | ||
tokenizer.Current.IsWhitespace() | ||
)) | ||
{ | ||
tokens.Add(tokenizer.Current); | ||
|
||
tokenizer.MoveNext(); | ||
} | ||
|
||
while ( | ||
tokenizer.Current != null && | ||
!tokenizer.Current.IsCharacter(TSQLCharacters.CloseParentheses)) | ||
{ | ||
while ( | ||
tokenizer.Current != null && | ||
( | ||
tokenizer.Current.IsComment() || | ||
tokenizer.Current.IsWhitespace() | ||
)) | ||
{ | ||
tokens.Add(tokenizer.Current); | ||
|
||
tokenizer.MoveNext(); | ||
} | ||
|
||
TSQLExpression argument = factory.Parse(tokenizer); | ||
|
||
tokens.AddRange(argument.Tokens); | ||
|
||
arguments.Add(argument); | ||
|
||
if (tokenizer.Current.IsCharacter(TSQLCharacters.Comma)) | ||
{ | ||
tokens.Add(tokenizer.Current); | ||
} | ||
|
||
if ( | ||
tokenizer.Current != null && | ||
!tokenizer.Current.IsCharacter(TSQLCharacters.CloseParentheses)) | ||
{ | ||
tokenizer.MoveNext(); | ||
} | ||
} | ||
|
||
TSQLArgumentList argList = new TSQLArgumentList( | ||
arguments); | ||
|
||
argList.Tokens.AddRange(tokens); | ||
|
||
return argList; | ||
} | ||
} | ||
} |
Oops, something went wrong.