/parsing/d/parameterunit.d

http://github.com/wilkie/djehuty · D · 83 lines · 47 code · 15 blank · 21 comment · 10 complexity · c8a2800888f7c430dc119b1d0877a9d4 MD5 · raw file

  1. /*
  2. * expressionunit.d
  3. *
  4. * This module parses expressions.
  5. *
  6. */
  7. module parsing.d.parameterunit;
  8. import parsing.parseunit;
  9. import parsing.token;
  10. import parsing.d.tokens;
  11. import parsing.d.nodes;
  12. import parsing.d.parameterlistunit;
  13. import parsing.d.functionbodyunit;
  14. import parsing.d.declaratorunit;
  15. import parsing.d.basictypeunit;
  16. import io.console;
  17. import djehuty;
  18. class ParameterUnit : ParseUnit {
  19. override bool tokenFound(Token current) {
  20. switch (current.type) {
  21. // Default Initializers
  22. case DToken.Assign:
  23. if (this.state < 1) {
  24. // Error: We don't have a declarator!
  25. // TODO:
  26. }
  27. // TODO:
  28. // auto tree = expand!(DefaultInitializerUnit)();
  29. // Done.
  30. return false;
  31. // Figure out the specifier.
  32. case DToken.In:
  33. case DToken.Out:
  34. case DToken.Ref:
  35. case DToken.Lazy:
  36. if (this.state >= 1) {
  37. // Error: Already have an in, out, ref, or lazy specifier.
  38. // TODO:
  39. }
  40. // Specifier.
  41. // Fall through to hit the declarator call
  42. default:
  43. lexer.push(current);
  44. if (this.state == 2) {
  45. // Could not find an equals
  46. // Done.
  47. lexer.push(current);
  48. return false;
  49. }
  50. if (this.state == 1) {
  51. // Could be a declarator then.
  52. auto tree = expand!(DeclaratorUnit)();
  53. this.state = 2;
  54. }
  55. else if (this.state == 0) {
  56. // Hopefully this is a BasicType
  57. auto tree = expand!(BasicTypeUnit)();
  58. this.state = 1;
  59. }
  60. break;
  61. }
  62. return true;
  63. }
  64. protected:
  65. string cur_string = "";
  66. static const string _common_error_msg = "";
  67. static const string[] _common_error_usages = null;
  68. }