40 lines
695 B
C++
40 lines
695 B
C++
#pragma once
|
|
/*
|
|
* Created by Brett on 17/11/23.
|
|
* Licensed under GNU General Public License V3.0
|
|
* See LICENSE file for license detail
|
|
*/
|
|
|
|
#ifndef BRAINFUCK_MISC_BF_TOKENIZER_H
|
|
#define BRAINFUCK_MISC_BF_TOKENIZER_H
|
|
|
|
#include <vector>
|
|
#include <string>
|
|
#include <optional>
|
|
|
|
enum class bf_token
|
|
{
|
|
INC_DP,
|
|
DEC_DP,
|
|
INC_DV,
|
|
DEC_DV,
|
|
PRINT,
|
|
READ,
|
|
OPEN,
|
|
CLOSE
|
|
};
|
|
|
|
struct token_t
|
|
{
|
|
bf_token token;
|
|
std::optional<std::string> name = {};
|
|
|
|
explicit token_t(bf_token token): token(token) {}
|
|
};
|
|
|
|
std::vector<token_t> tokenize(const std::string& program);
|
|
std::vector<token_t>& bf_name(std::vector<token_t>& tokens);
|
|
|
|
|
|
#endif //BRAINFUCK_MISC_BF_TOKENIZER_H
|