You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

29 rivejä
891 B

#pragma once
#include "molasses/lexer.h"
#include "molasses/parser_primitives.h"
#include <memory>
#include <span>
#include <vector>
struct parser {
/**
*
* @param ctx
* @param lexer_data
* @param current
* @return a span of the tokens left before reaching the target, assuming the parser is as greedy as possible
*/
virtual std::span<molasses::symbol> identify(molasses::parser_context& ctx, const molasses::lexed_output& lexer_data, std::span<molasses::symbol> current) = 0;
};
struct ast_node {
virtual std::vector<molasses::symbol> apply(molasses::parser_context& ctx, const molasses::lexed_output& lexer_data, std::span<molasses::symbol> current) = 0;
};
struct parser_branch : public parser {
std::vector<std::shared_ptr<parser>> choice;
};
struct parser_sequence : public parser {
std::vector<std::shared_ptr<parser>> sequence;
};