Created
October 26, 2016 03:42
-
-
Save toptensoftware/17f7643551b41032911d0fb433416d1b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // Variable | |
| if (_tokenizer.Token == Token.Identifier) | |
| { | |
| // Capture the name and skip it | |
| var name = _tokenizer.Identifier; | |
| _tokenizer.NextToken(); | |
| // Parens indicate a function call, otherwise just a variable | |
| if (_tokenizer.Token != Token.OpenParens) | |
| { | |
| // Variable | |
| return new NodeVariable(name); | |
| } | |
| else | |
| { | |
| // Function call | |
| // Skip parens | |
| _tokenizer.NextToken(); | |
| // Parse arguments | |
| var arguments = new List<Node>(); | |
| while (true) | |
| { | |
| // Parse argument and add to list | |
| arguments.Add(ParseAddSubtract()); | |
| // Is there another argument? | |
| if (_tokenizer.Token == Token.Comma) | |
| { | |
| _tokenizer.NextToken(); | |
| continue; | |
| } | |
| // Get out | |
| break; | |
| } | |
| // Check and skip ')' | |
| if (_tokenizer.Token != Token.CloseParens) | |
| throw new SyntaxException("Missing close parenthesis"); | |
| _tokenizer.NextToken(); | |
| // Create the function call node | |
| return new NodeFunctionCall(name, arguments.ToArray()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment