/parsing/d/pragmastmtunit.d

http://github.com/wilkie/djehuty · D · 72 lines · 45 code · 15 blank · 12 comment · 12 complexity · 289f0ceba3cb9a18e3ed21dca133165e MD5 · raw file

  1. /*
  2. * expressionunit.d
  3. *
  4. * This module parses expressions.
  5. *
  6. */
  7. module parsing.d.pragmastmtunit;
  8. import parsing.parseunit;
  9. import parsing.token;
  10. import parsing.d.tokens;
  11. import parsing.d.nodes;
  12. import parsing.d.statementunit;
  13. import io.console;
  14. import djehuty;
  15. class PragmaStmtUnit : ParseUnit {
  16. override bool tokenFound(Token current) {
  17. switch (current.type) {
  18. case DToken.LeftParen:
  19. if(this.state >= 1){
  20. //XXX: Error
  21. }
  22. this.state = 1;
  23. break;
  24. case DToken.Identifier:
  25. if(this.state != 1){
  26. //XXX: Error
  27. }
  28. cur_string = current.value.toString();
  29. Console.putln("Pragma: ", current.value);
  30. this.state = 2;
  31. break;
  32. case DToken.RightParen:
  33. if(this.state != 2 && this.state != 3){
  34. //XXX: Error
  35. }
  36. if (this.state == 2) {
  37. auto tree = expand!(StatementUnit)();
  38. }
  39. // Done.
  40. return false;
  41. case DToken.Comma:
  42. if(this.state != 2){
  43. //XXX: Error
  44. }
  45. this.state = 3;
  46. //TODO: Argument List
  47. break;
  48. default:
  49. break;
  50. }
  51. return true;
  52. }
  53. protected:
  54. string cur_string = "";
  55. static const string _common_error_msg = "";
  56. static const string[] _common_error_usages = null;
  57. }