Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. // Variable
  2. if (_tokenizer.Token == Token.Identifier)
  3. {
  4. // Capture the name and skip it
  5. var name = _tokenizer.Identifier;
  6. _tokenizer.NextToken();
  7.  
  8. // Parens indicate a function call, otherwise just a variable
  9. if (_tokenizer.Token != Token.OpenParens)
  10. {
  11. // Variable
  12. return new NodeVariable(name);
  13. }
  14. else
  15. {
  16. // Function call
  17.  
  18. // Skip parens
  19. _tokenizer.NextToken();
  20.  
  21. // Parse arguments
  22. var arguments = new List<Node>();
  23. while (true)
  24. {
  25. // Parse argument and add to list
  26. arguments.Add(ParseAddSubtract());
  27.  
  28. // Is there another argument?
  29. if (_tokenizer.Token == Token.Comma)
  30. {
  31. _tokenizer.NextToken();
  32. continue;
  33. }
  34.  
  35. // Get out
  36. break;
  37. }
  38.  
  39. // Check and skip ')'
  40. if (_tokenizer.Token != Token.CloseParens)
  41. throw new SyntaxException("Missing close parenthesis");
  42. _tokenizer.NextToken();
  43.  
  44. // Create the function call node
  45. return new NodeFunctionCall(name, arguments.ToArray());
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement