/parsing/d/enumbodyunit.d

http://github.com/wilkie/djehuty · D · 64 lines · 39 code · 12 blank · 13 comment · 7 complexity · f41ec28a2f50f8900fe31db13f722b05 MD5 · raw file

  1. /*
  2. * expressionunit.d
  3. *
  4. * This module parses expressions.
  5. *
  6. */
  7. module parsing.d.enumbodyunit;
  8. import parsing.parseunit;
  9. import parsing.token;
  10. import parsing.d.tokens;
  11. import parsing.d.nodes;
  12. import parsing.d.assignexprunit;
  13. import io.console;
  14. import djehuty;
  15. class EnumBodyUnit : ParseUnit {
  16. override bool tokenFound(Token current) {
  17. switch (current.type) {
  18. // Looking for a new member name
  19. case DToken.Identifier:
  20. if (this.state == 1) {
  21. // Error: A name next to a name??
  22. }
  23. this.state = 1;
  24. Console.putln("Member: ", current.value);
  25. break;
  26. case DToken.RightCurly:
  27. // Done.
  28. return false;
  29. case DToken.Comma:
  30. if (this.state != 1) {
  31. // Error: A comma by itself?
  32. }
  33. this.state = 0;
  34. break;
  35. case DToken.Assign:
  36. if (this.state != 1) {
  37. // Error: An equals by itself?
  38. }
  39. // Look for an assignment expression.
  40. auto tree = expand!(AssignExprUnit)();
  41. // Stay in the same state and wait for a comma.
  42. break;
  43. default:
  44. break;
  45. }
  46. return true;
  47. }
  48. protected:
  49. string cur_string = "";
  50. static const string _common_error_msg = "";
  51. static const string[] _common_error_usages = null;
  52. }