PageRenderTime 7ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/parsing/d/declaratorsuffixunit.d

http://github.com/wilkie/djehuty
D | 89 lines | 57 code | 14 blank | 18 comment | 4 complexity | c59950b4e9f46fc9f65ecfe5c6aec585 MD5 | raw file
  1. /*
  2. * expressionunit.d
  3. *
  4. * This module parses expressions.
  5. *
  6. */
  7. module parsing.d.declaratorsuffixunit;
  8. import parsing.parseunit;
  9. import parsing.token;
  10. import parsing.d.tokens;
  11. import parsing.d.nodes;
  12. import parsing.d.expressionunit;
  13. import io.console;
  14. import djehuty;
  15. class DeclaratorSuffixUnit : ParseUnit {
  16. override bool tokenFound(Token current) {
  17. switch (this.state) {
  18. case 0:
  19. // Looking for ( or [
  20. // Types which have () or [] after them
  21. switch (current.type) {
  22. case DToken.LeftParen:
  23. this.state = 1;
  24. break;
  25. case DToken.LeftBracket:
  26. this.state = 2;
  27. break;
  28. default:
  29. break;
  30. }
  31. break;
  32. case 1:
  33. // We have found a ( so we are searching for
  34. // a right parenthesis
  35. switch (current.type) {
  36. case DToken.RightParen:
  37. // Done
  38. Console.putln("()");
  39. break;
  40. default:
  41. // This is a parameter list
  42. // XXX:
  43. // auto tree = expand!(ParameterList)();
  44. break;
  45. }
  46. return false;
  47. case 2:
  48. // We have found a [ so we are searching for
  49. // a right bracket.
  50. switch (current.type) {
  51. case DToken.RightBracket:
  52. Console.putln("[]");
  53. // Done
  54. return false;
  55. case DToken.Dot:
  56. break;
  57. case DToken.Identifier:
  58. break;
  59. default:
  60. // We should assume it is an expression
  61. lexer.push(current);
  62. auto tree = expand!(ExpressionUnit)();
  63. break;
  64. }
  65. break;
  66. default:
  67. break;
  68. }
  69. return true;
  70. }
  71. protected:
  72. string cur_string = "";
  73. static const string _common_error_msg = "";
  74. static const string[] _common_error_usages = null;
  75. }