/parsing/d/functionbodyunit.d

http://github.com/wilkie/djehuty · D · 73 lines · 45 code · 14 blank · 14 comment · 9 complexity · 196ee39cd304c65fe0a272a7d1081c4f MD5 · raw file

  1. /*
  2. * expressionunit.d
  3. *
  4. * This module parses expressions.
  5. *
  6. */
  7. module parsing.d.functionbodyunit;
  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.statementunit;
  15. import io.console;
  16. import djehuty;
  17. class FunctionBodyUnit : ParseUnit {
  18. override bool tokenFound(Token current) {
  19. switch (current.type) {
  20. // We always look FIRST for a left curly brace
  21. case DToken.LeftCurly:
  22. if (this.state % 2 == 1) {
  23. // Error: Left curly already found.
  24. // TODO:
  25. }
  26. this.state = this.state + 1;
  27. break;
  28. // We are always looking for the end of the block.
  29. case DToken.RightCurly:
  30. if (this.state % 2 == 0) {
  31. // Error: Left curly not found!
  32. // TODO:
  33. }
  34. this.state = this.state - 1;
  35. if (this.state == 0) {
  36. // Done.
  37. return false;
  38. }
  39. // TODO: in, out, body, blockstatement foo
  40. case DToken.In:
  41. break;
  42. case DToken.Out:
  43. break;
  44. case DToken.Body:
  45. break;
  46. default:
  47. lexer.push(current);
  48. if (this.state % 2 == 0) {
  49. }
  50. auto tree = expand!(StatementUnit)();
  51. break;
  52. }
  53. return true;
  54. }
  55. protected:
  56. string cur_string = "";
  57. static const string _common_error_msg = "";
  58. static const string[] _common_error_usages = null;
  59. }