#ifndef RUBY_PARSER_CONTEXT_HH #define RUBY_PARSER_CONTEXT_HH #include #include #include namespace ruby_parser { class Context { public: enum class State { CLASS, SCLASS, DEF, DEFS, BLOCK, LAMBDA, }; void push(State state); void pop(); void reset(); bool inClass(); bool indirectlyInDef(); bool classDefintinionAllowed(); bool moduleDefintinionAllowed(); bool dynamicConstDefintinionAllowed(); private: std::vector stack; std::optional firstIndexOfState(State state); std::optional lastIndexOfState(State state); bool contains(State state); }; } // namespace ruby_parser #endif