builder.hh 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #ifndef RUBY_PARSER_BUILDER_HH
  2. #define RUBY_PARSER_BUILDER_HH
  3. #include <vector>
  4. #include <memory>
  5. #include <type_traits>
  6. #include "node.hh"
  7. #include "token.hh"
  8. #include "driver.hh"
  9. namespace ruby_parser {
  10. struct builder {
  11. ForeignPtr(*accessible)(SelfPtr builder, ForeignPtr node);
  12. ForeignPtr(*alias)(SelfPtr builder, const token* alias, ForeignPtr to, ForeignPtr from);
  13. ForeignPtr(*arg)(SelfPtr builder, const token* name);
  14. ForeignPtr(*args)(SelfPtr builder, const token* begin, const node_list* args, const token* end, bool check_args);
  15. ForeignPtr(*array)(SelfPtr builder, const token* begin, const node_list* elements, const token* end);
  16. ForeignPtr(*assign)(SelfPtr builder, ForeignPtr lhs, const token* eql, ForeignPtr rhs);
  17. ForeignPtr(*assignable)(SelfPtr builder, ForeignPtr node);
  18. ForeignPtr(*associate)(SelfPtr builder, const token* begin, const node_list* pairs, const token* end);
  19. ForeignPtr(*attrAsgn)(SelfPtr builder, ForeignPtr receiver, const token* dot, const token* selector);
  20. ForeignPtr(*backRef)(SelfPtr builder, const token* tok);
  21. ForeignPtr(*begin)(SelfPtr builder, const token* begin, ForeignPtr body, const token* end);
  22. ForeignPtr(*beginBody)(SelfPtr builder, ForeignPtr body, const node_list* rescueBodies, const token* elseTok, ForeignPtr else_, const token* ensure_tok, ForeignPtr ensure);
  23. ForeignPtr(*beginKeyword)(SelfPtr builder, const token* begin, ForeignPtr body, const token* end);
  24. ForeignPtr(*binaryOp)(SelfPtr builder, ForeignPtr receiver, const token* oper, ForeignPtr arg);
  25. ForeignPtr(*block)(SelfPtr builder, ForeignPtr methodCall, const token* begin, ForeignPtr args, ForeignPtr body, const token* end);
  26. ForeignPtr(*blockPass)(SelfPtr builder, const token* amper, ForeignPtr arg);
  27. ForeignPtr(*blockarg)(SelfPtr builder, const token* amper, const token* name);
  28. ForeignPtr(*callLambda)(SelfPtr builder, const token* lambda);
  29. ForeignPtr(*call_method)(SelfPtr builder, ForeignPtr receiver, const token* dot, const token* selector, const token* lparen, const node_list* args, const token* rparen);
  30. ForeignPtr(*case_)(SelfPtr builder, const token* case_, ForeignPtr expr, const node_list* whenBodies, const token* elseTok, ForeignPtr elseBody, const token* end);
  31. ForeignPtr(*character)(SelfPtr builder, const token* char_);
  32. ForeignPtr(*complex)(SelfPtr builder, const token* tok);
  33. ForeignPtr(*compstmt)(SelfPtr builder, const node_list* node);
  34. ForeignPtr(*condition)(SelfPtr builder, const token* cond_tok, ForeignPtr cond, const token* then, ForeignPtr ifTrue, const token* else_, ForeignPtr ifFalse, const token* end);
  35. ForeignPtr(*conditionMod)(SelfPtr builder, ForeignPtr ifTrue, ForeignPtr ifFalse, ForeignPtr cond);
  36. ForeignPtr(*const_)(SelfPtr builder, const token* name);
  37. ForeignPtr(*constFetch)(SelfPtr builder, ForeignPtr scope, const token* colon, const token* name);
  38. ForeignPtr(*constGlobal)(SelfPtr builder, const token* colon, const token* name);
  39. ForeignPtr(*constOpAssignable)(SelfPtr builder, ForeignPtr node);
  40. ForeignPtr(*cvar)(SelfPtr builder, const token* tok);
  41. ForeignPtr(*dedentString)(SelfPtr builder, ForeignPtr node, size_t dedentLevel);
  42. ForeignPtr(*def_class)(SelfPtr builder, const token* class_, ForeignPtr name, const token* lt_, ForeignPtr superclass, ForeignPtr body, const token* end_);
  43. ForeignPtr(*defMethod)(SelfPtr builder, const token* def, const token* name, ForeignPtr args, ForeignPtr body, const token* end);
  44. ForeignPtr(*defModule)(SelfPtr builder, const token* module, ForeignPtr name, ForeignPtr body, const token* end_);
  45. ForeignPtr(*def_sclass)(SelfPtr builder, const token* class_, const token* lshft_, ForeignPtr expr, ForeignPtr body, const token* end_);
  46. ForeignPtr(*defSingleton)(SelfPtr builder, const token* def, ForeignPtr definee, const token* dot, const token* name, ForeignPtr args, ForeignPtr body, const token* end);
  47. ForeignPtr(*encodingLiteral)(SelfPtr builder, const token* tok);
  48. ForeignPtr(*false_)(SelfPtr builder, const token* tok);
  49. ForeignPtr(*fileLiteral)(SelfPtr builder, const token* tok);
  50. ForeignPtr(*float_)(SelfPtr builder, const token* tok);
  51. ForeignPtr(*floatComplex)(SelfPtr builder, const token* tok);
  52. ForeignPtr(*for_)(SelfPtr builder, const token* for_, ForeignPtr iterator, const token* in_, ForeignPtr iteratee, const token* do_, ForeignPtr body, const token* end);
  53. ForeignPtr(*gvar)(SelfPtr builder, const token* tok);
  54. ForeignPtr(*ident)(SelfPtr builder, const token* tok);
  55. ForeignPtr(*index)(SelfPtr builder, ForeignPtr receiver, const token* lbrack, const node_list* indexes, const token* rbrack);
  56. ForeignPtr(*indexAsgn)(SelfPtr builder, ForeignPtr receiver, const token* lbrack, const node_list* indexes, const token* rbrack);
  57. ForeignPtr(*integer)(SelfPtr builder, const token* tok);
  58. ForeignPtr(*ivar)(SelfPtr builder, const token* tok);
  59. ForeignPtr(*keywordBreak)(SelfPtr builder, const token* keyword, const token* lparen, const node_list* args, const token* rparen);
  60. ForeignPtr(*keywordDefined)(SelfPtr builder, const token* keyword, ForeignPtr arg);
  61. ForeignPtr(*keywordNext)(SelfPtr builder, const token* keyword, const token* lparen, const node_list* args, const token* rparen);
  62. ForeignPtr(*keywordRedo)(SelfPtr builder, const token* keyword);
  63. ForeignPtr(*keywordRetry)(SelfPtr builder, const token* keyword);
  64. ForeignPtr(*keywordReturn)(SelfPtr builder, const token* keyword, const token* lparen, const node_list* args, const token* rparen);
  65. ForeignPtr(*keywordSuper)(SelfPtr builder, const token* keyword, const token* lparen, const node_list* args, const token* rparen);
  66. ForeignPtr(*keywordYield)(SelfPtr builder, const token* keyword, const token* lparen, const node_list* args, const token* rparen);
  67. ForeignPtr(*keywordZsuper)(SelfPtr builder, const token* keyword);
  68. ForeignPtr(*kwarg)(SelfPtr builder, const token* name);
  69. ForeignPtr(*kwoptarg)(SelfPtr builder, const token* name, ForeignPtr value);
  70. ForeignPtr(*kwrestarg)(SelfPtr builder, const token* dstar, const token* name);
  71. ForeignPtr(*kwsplat)(SelfPtr builder, const token* dstar, ForeignPtr arg);
  72. ForeignPtr(*line_literal)(SelfPtr builder, const token* tok);
  73. ForeignPtr(*logicalAnd)(SelfPtr builder, ForeignPtr lhs, const token* op, ForeignPtr rhs);
  74. ForeignPtr(*logicalOr)(SelfPtr builder, ForeignPtr lhs, const token* op, ForeignPtr rhs);
  75. ForeignPtr(*loopUntil)(SelfPtr builder, const token* keyword, ForeignPtr cond, const token* do_, ForeignPtr body, const token* end);
  76. ForeignPtr(*loopUntil_mod)(SelfPtr builder, ForeignPtr body, ForeignPtr cond);
  77. ForeignPtr(*loop_while)(SelfPtr builder, const token* keyword, ForeignPtr cond, const token* do_, ForeignPtr body, const token* end);
  78. ForeignPtr(*loop_while_mod)(SelfPtr builder, ForeignPtr body, ForeignPtr cond);
  79. ForeignPtr(*match_op)(SelfPtr builder, ForeignPtr receiver, const token* oper, ForeignPtr arg);
  80. ForeignPtr(*multi_assign)(SelfPtr builder, ForeignPtr mlhs, ForeignPtr rhs);
  81. ForeignPtr(*multi_lhs)(SelfPtr builder, const token* begin, const node_list* items, const token* end);
  82. ForeignPtr(*multi_lhs1)(SelfPtr builder, const token* begin, ForeignPtr item, const token* end);
  83. ForeignPtr(*nil)(SelfPtr builder, const token* tok);
  84. ForeignPtr(*not_op)(SelfPtr builder, const token* not_, const token* begin, ForeignPtr receiver, const token* end);
  85. ForeignPtr(*nth_ref)(SelfPtr builder, const token* tok);
  86. ForeignPtr(*op_assign)(SelfPtr builder, ForeignPtr lhs, const token* op, ForeignPtr rhs);
  87. ForeignPtr(*optarg)(SelfPtr builder, const token* name, const token* eql, ForeignPtr value);
  88. ForeignPtr(*pair)(SelfPtr builder, ForeignPtr key, const token* assoc, ForeignPtr value);
  89. ForeignPtr(*pair_keyword)(SelfPtr builder, const token* key, ForeignPtr value);
  90. ForeignPtr(*pair_quoted)(SelfPtr builder, const token* begin, const node_list* parts, const token* end, ForeignPtr value);
  91. ForeignPtr(*postexe)(SelfPtr builder, const token* begin, ForeignPtr node, const token* rbrace);
  92. ForeignPtr(*preexe)(SelfPtr builder, const token* begin, ForeignPtr node, const token* rbrace);
  93. ForeignPtr(*procarg0)(SelfPtr builder, ForeignPtr arg);
  94. ForeignPtr(*range_exclusive)(SelfPtr builder, ForeignPtr lhs, const token* oper, ForeignPtr rhs);
  95. ForeignPtr(*range_inclusive)(SelfPtr builder, ForeignPtr lhs, const token* oper, ForeignPtr rhs);
  96. ForeignPtr(*rational)(SelfPtr builder, const token* tok);
  97. ForeignPtr(*rational_complex)(SelfPtr builder, const token* tok);
  98. ForeignPtr(*regexp_compose)(SelfPtr builder, const token* begin, const node_list* parts, const token* end, ForeignPtr options);
  99. ForeignPtr(*regexp_options)(SelfPtr builder, const token* regopt);
  100. ForeignPtr(*rescue_body)(SelfPtr builder, const token* rescue, ForeignPtr excList, const token* assoc, ForeignPtr excVar, const token* then, ForeignPtr body);
  101. ForeignPtr(*restarg)(SelfPtr builder, const token* star, const token* name);
  102. ForeignPtr(*self_)(SelfPtr builder, const token* tok);
  103. ForeignPtr(*shadowarg)(SelfPtr builder, const token* name);
  104. ForeignPtr(*splat)(SelfPtr builder, const token* star, ForeignPtr arg);
  105. ForeignPtr(*splat_mlhs)(SelfPtr builder, const token* star, ForeignPtr arg);
  106. ForeignPtr(*string)(SelfPtr builder, const token* string_);
  107. ForeignPtr(*string_compose)(SelfPtr builder, const token* begin, const node_list* parts, const token* end);
  108. ForeignPtr(*string_internal)(SelfPtr builder, const token* string_);
  109. ForeignPtr(*symbol)(SelfPtr builder, const token* symbol);
  110. ForeignPtr(*symbol_compose)(SelfPtr builder, const token* begin, const node_list* parts, const token* end);
  111. ForeignPtr(*symbol_internal)(SelfPtr builder, const token* symbol);
  112. ForeignPtr(*symbols_compose)(SelfPtr builder, const token* begin, const node_list* parts, const token* end);
  113. ForeignPtr(*ternary)(SelfPtr builder, ForeignPtr cond, const token* question, ForeignPtr ifTrue, const token* colon, ForeignPtr ifFalse);
  114. ForeignPtr(*true_)(SelfPtr builder, const token* tok);
  115. ForeignPtr(*unary_op)(SelfPtr builder, const token* oper, ForeignPtr receiver);
  116. ForeignPtr(*undefMethod)(SelfPtr builder, const token* undef, const node_list* name_list);
  117. ForeignPtr(*when)(SelfPtr builder, const token* when, const node_list* patterns, const token* then, ForeignPtr body);
  118. ForeignPtr(*word)(SelfPtr builder, const node_list* parts);
  119. ForeignPtr(*words_compose)(SelfPtr builder, const token* begin, const node_list* parts, const token* end);
  120. ForeignPtr(*xstring_compose)(SelfPtr builder, const token* begin, const node_list* parts, const token* end);
  121. };
  122. static_assert(std::is_pod<builder>::value, "`builder` must be a POD type");
  123. }
  124. #endif