/parsing/d/gotostmtunit.d

http://github.com/wilkie/djehuty · D · 76 lines · 49 code · 10 blank · 17 comment · 11 complexity · c89688e6ebca46826d6dc946fb4f45c4 MD5 · raw file

  1. /*
  2. * expressionunit.d
  3. *
  4. * This module parses expressions.
  5. *
  6. */
  7. module parsing.d.gotostmtunit;
  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 GotoStmtUnit : ParseUnit {
  16. override bool tokenFound(Token current) {
  17. switch (current.type) {
  18. case DToken.Semicolon:
  19. if (this.state == 0) {
  20. // Error.
  21. // TODO:
  22. }
  23. if (this.state == 2) {
  24. // Error.
  25. // TODO:
  26. }
  27. // Done.
  28. return false;
  29. case DToken.Identifier:
  30. if (this.state != 0) {
  31. // Error
  32. // TODO:
  33. }
  34. Console.putln("Goto: ", current.value);
  35. cur_string = current.value.toString();
  36. this.state = 1;
  37. break;
  38. case DToken.Default:
  39. Console.putln("Goto: Default");
  40. this.state = 2;
  41. break;
  42. case DToken.Case:
  43. Console.putln("Goto: Case");
  44. this.state = 2;
  45. break;
  46. default:
  47. if (this.state != 2) {
  48. // Error
  49. // TODO:
  50. }
  51. lexer.push(current);
  52. if (this.state == 3) {
  53. // Error: Multiple expressions
  54. // TODO:
  55. }
  56. auto tree = expand!(ExpressionUnit)();
  57. this.state = 3;
  58. break;
  59. }
  60. return true;
  61. }
  62. protected:
  63. string cur_string = "";
  64. static const string _common_error_msg = "";
  65. static const string[] _common_error_usages = null;
  66. }