Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

29 rader
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;
};