Trim commit tree
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
NEWLINE=1
|
||||
COMMENT=2
|
||||
WS=3
|
||||
LOOPSTART=4
|
||||
LOOPEND=5
|
||||
NUMBER=6
|
||||
INPUT=7
|
||||
OUTPUT=8
|
||||
DEC=9
|
||||
INC=10
|
||||
LEFT=11
|
||||
RIGHT=12
|
||||
'\n'=1
|
||||
'['=4
|
||||
']'=5
|
||||
'?'=7
|
||||
'.'=8
|
||||
'-'=9
|
||||
'+'=10
|
||||
'>'=11
|
||||
'<'=12
|
@@ -1,7 +0,0 @@
|
||||
|
||||
// Generated from /home/atreya/Documents/Projects/Miscellaneous/bfc/grammar/bf.g4 by ANTLR 4.8
|
||||
|
||||
|
||||
#include "bfBaseListener.h"
|
||||
|
||||
|
@@ -1,47 +0,0 @@
|
||||
|
||||
// Generated from /home/atreya/Documents/Projects/Miscellaneous/bfc/grammar/bf.g4 by ANTLR 4.8
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "antlr4-runtime.h"
|
||||
#include "bfListener.h"
|
||||
|
||||
|
||||
/**
|
||||
* This class provides an empty implementation of bfListener,
|
||||
* which can be extended to create a listener which only needs to handle a subset
|
||||
* of the available methods.
|
||||
*/
|
||||
class bfBaseListener : public bfListener {
|
||||
public:
|
||||
|
||||
virtual void enterProgram(bfParser::ProgramContext * /*ctx*/) override { }
|
||||
virtual void exitProgram(bfParser::ProgramContext * /*ctx*/) override { }
|
||||
|
||||
virtual void enterStatements(bfParser::StatementsContext * /*ctx*/) override { }
|
||||
virtual void exitStatements(bfParser::StatementsContext * /*ctx*/) override { }
|
||||
|
||||
virtual void enterLoopStmt(bfParser::LoopStmtContext * /*ctx*/) override { }
|
||||
virtual void exitLoopStmt(bfParser::LoopStmtContext * /*ctx*/) override { }
|
||||
|
||||
virtual void enterNumberedStatement(bfParser::NumberedStatementContext * /*ctx*/) override { }
|
||||
virtual void exitNumberedStatement(bfParser::NumberedStatementContext * /*ctx*/) override { }
|
||||
|
||||
virtual void enterStatement(bfParser::StatementContext * /*ctx*/) override { }
|
||||
virtual void exitStatement(bfParser::StatementContext * /*ctx*/) override { }
|
||||
|
||||
virtual void enterInputStmt(bfParser::InputStmtContext * /*ctx*/) override { }
|
||||
virtual void exitInputStmt(bfParser::InputStmtContext * /*ctx*/) override { }
|
||||
|
||||
virtual void enterOutputStmt(bfParser::OutputStmtContext * /*ctx*/) override { }
|
||||
virtual void exitOutputStmt(bfParser::OutputStmtContext * /*ctx*/) override { }
|
||||
|
||||
|
||||
virtual void enterEveryRule(antlr4::ParserRuleContext * /*ctx*/) override { }
|
||||
virtual void exitEveryRule(antlr4::ParserRuleContext * /*ctx*/) override { }
|
||||
virtual void visitTerminal(antlr4::tree::TerminalNode * /*node*/) override { }
|
||||
virtual void visitErrorNode(antlr4::tree::ErrorNode * /*node*/) override { }
|
||||
|
||||
};
|
||||
|
@@ -1,7 +0,0 @@
|
||||
|
||||
// Generated from /home/atreya/Documents/Projects/Miscellaneous/bfc/grammar/bf.g4 by ANTLR 4.8
|
||||
|
||||
|
||||
#include "bfBaseVisitor.h"
|
||||
|
||||
|
@@ -1,48 +0,0 @@
|
||||
|
||||
// Generated from /home/atreya/Documents/Projects/Miscellaneous/bfc/grammar/bf.g4 by ANTLR 4.8
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "antlr4-runtime.h"
|
||||
#include "bfVisitor.h"
|
||||
|
||||
|
||||
/**
|
||||
* This class provides an empty implementation of bfVisitor, which can be
|
||||
* extended to create a visitor which only needs to handle a subset of the available methods.
|
||||
*/
|
||||
class bfBaseVisitor : public bfVisitor {
|
||||
public:
|
||||
|
||||
virtual antlrcpp::Any visitProgram(bfParser::ProgramContext *ctx) override {
|
||||
return visitChildren(ctx);
|
||||
}
|
||||
|
||||
virtual antlrcpp::Any visitStatements(bfParser::StatementsContext *ctx) override {
|
||||
return visitChildren(ctx);
|
||||
}
|
||||
|
||||
virtual antlrcpp::Any visitLoopStmt(bfParser::LoopStmtContext *ctx) override {
|
||||
return visitChildren(ctx);
|
||||
}
|
||||
|
||||
virtual antlrcpp::Any visitNumberedStatement(bfParser::NumberedStatementContext *ctx) override {
|
||||
return visitChildren(ctx);
|
||||
}
|
||||
|
||||
virtual antlrcpp::Any visitStatement(bfParser::StatementContext *ctx) override {
|
||||
return visitChildren(ctx);
|
||||
}
|
||||
|
||||
virtual antlrcpp::Any visitInputStmt(bfParser::InputStmtContext *ctx) override {
|
||||
return visitChildren(ctx);
|
||||
}
|
||||
|
||||
virtual antlrcpp::Any visitOutputStmt(bfParser::OutputStmtContext *ctx) override {
|
||||
return visitChildren(ctx);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
@@ -1,168 +0,0 @@
|
||||
|
||||
// Generated from /home/atreya/Documents/Projects/Miscellaneous/bfc/grammar/bf.g4 by ANTLR 4.8
|
||||
|
||||
|
||||
#include "bfLexer.h"
|
||||
|
||||
|
||||
using namespace antlr4;
|
||||
|
||||
|
||||
bfLexer::bfLexer(CharStream *input) : Lexer(input) {
|
||||
_interpreter = new atn::LexerATNSimulator(this, _atn, _decisionToDFA, _sharedContextCache);
|
||||
}
|
||||
|
||||
bfLexer::~bfLexer() {
|
||||
delete _interpreter;
|
||||
}
|
||||
|
||||
std::string bfLexer::getGrammarFileName() const {
|
||||
return "bf.g4";
|
||||
}
|
||||
|
||||
const std::vector<std::string>& bfLexer::getRuleNames() const {
|
||||
return _ruleNames;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& bfLexer::getChannelNames() const {
|
||||
return _channelNames;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& bfLexer::getModeNames() const {
|
||||
return _modeNames;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& bfLexer::getTokenNames() const {
|
||||
return _tokenNames;
|
||||
}
|
||||
|
||||
dfa::Vocabulary& bfLexer::getVocabulary() const {
|
||||
return _vocabulary;
|
||||
}
|
||||
|
||||
const std::vector<uint16_t> bfLexer::getSerializedATN() const {
|
||||
return _serializedATN;
|
||||
}
|
||||
|
||||
const atn::ATN& bfLexer::getATN() const {
|
||||
return _atn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Static vars and initialization.
|
||||
std::vector<dfa::DFA> bfLexer::_decisionToDFA;
|
||||
atn::PredictionContextCache bfLexer::_sharedContextCache;
|
||||
|
||||
// We own the ATN which in turn owns the ATN states.
|
||||
atn::ATN bfLexer::_atn;
|
||||
std::vector<uint16_t> bfLexer::_serializedATN;
|
||||
|
||||
std::vector<std::string> bfLexer::_ruleNames = {
|
||||
u8"NEWLINE", u8"COMMENT", u8"WS", u8"LOOPSTART", u8"LOOPEND", u8"NUMBER",
|
||||
u8"INPUT", u8"OUTPUT", u8"DEC", u8"INC", u8"LEFT", u8"RIGHT"
|
||||
};
|
||||
|
||||
std::vector<std::string> bfLexer::_channelNames = {
|
||||
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
|
||||
};
|
||||
|
||||
std::vector<std::string> bfLexer::_modeNames = {
|
||||
u8"DEFAULT_MODE"
|
||||
};
|
||||
|
||||
std::vector<std::string> bfLexer::_literalNames = {
|
||||
"", u8"'\n'", "", "", u8"'['", u8"']'", "", u8"'?'", u8"'.'", u8"'-'",
|
||||
u8"'+'", u8"'>'", u8"'<'"
|
||||
};
|
||||
|
||||
std::vector<std::string> bfLexer::_symbolicNames = {
|
||||
"", u8"NEWLINE", u8"COMMENT", u8"WS", u8"LOOPSTART", u8"LOOPEND", u8"NUMBER",
|
||||
u8"INPUT", u8"OUTPUT", u8"DEC", u8"INC", u8"LEFT", u8"RIGHT"
|
||||
};
|
||||
|
||||
dfa::Vocabulary bfLexer::_vocabulary(_literalNames, _symbolicNames);
|
||||
|
||||
std::vector<std::string> bfLexer::_tokenNames;
|
||||
|
||||
bfLexer::Initializer::Initializer() {
|
||||
// This code could be in a static initializer lambda, but VS doesn't allow access to private class members from there.
|
||||
for (size_t i = 0; i < _symbolicNames.size(); ++i) {
|
||||
std::string name = _vocabulary.getLiteralName(i);
|
||||
if (name.empty()) {
|
||||
name = _vocabulary.getSymbolicName(i);
|
||||
}
|
||||
|
||||
if (name.empty()) {
|
||||
_tokenNames.push_back("<INVALID>");
|
||||
} else {
|
||||
_tokenNames.push_back(name);
|
||||
}
|
||||
}
|
||||
|
||||
_serializedATN = {
|
||||
0x3, 0x608b, 0xa72a, 0x8133, 0xb9ed, 0x417c, 0x3be7, 0x7786, 0x5964,
|
||||
0x2, 0xe, 0x49, 0x8, 0x1, 0x4, 0x2, 0x9, 0x2, 0x4, 0x3, 0x9, 0x3, 0x4,
|
||||
0x4, 0x9, 0x4, 0x4, 0x5, 0x9, 0x5, 0x4, 0x6, 0x9, 0x6, 0x4, 0x7, 0x9,
|
||||
0x7, 0x4, 0x8, 0x9, 0x8, 0x4, 0x9, 0x9, 0x9, 0x4, 0xa, 0x9, 0xa, 0x4,
|
||||
0xb, 0x9, 0xb, 0x4, 0xc, 0x9, 0xc, 0x4, 0xd, 0x9, 0xd, 0x3, 0x2, 0x3,
|
||||
0x2, 0x3, 0x2, 0x3, 0x2, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x7,
|
||||
0x3, 0x24, 0xa, 0x3, 0xc, 0x3, 0xe, 0x3, 0x27, 0xb, 0x3, 0x3, 0x3, 0x5,
|
||||
0x3, 0x2a, 0xa, 0x3, 0x3, 0x3, 0x5, 0x3, 0x2d, 0xa, 0x3, 0x3, 0x3, 0x3,
|
||||
0x3, 0x3, 0x4, 0x3, 0x4, 0x3, 0x4, 0x3, 0x4, 0x3, 0x5, 0x3, 0x5, 0x3,
|
||||
0x6, 0x3, 0x6, 0x3, 0x7, 0x6, 0x7, 0x3a, 0xa, 0x7, 0xd, 0x7, 0xe, 0x7,
|
||||
0x3b, 0x3, 0x8, 0x3, 0x8, 0x3, 0x9, 0x3, 0x9, 0x3, 0xa, 0x3, 0xa, 0x3,
|
||||
0xb, 0x3, 0xb, 0x3, 0xc, 0x3, 0xc, 0x3, 0xd, 0x3, 0xd,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||||
0x37, 0x7, 0x5f, 0x2, 0x2, 0x37, 0xc, 0x3, 0x2, 0x2, 0x2, 0x38, 0x3a,
|
||||
0x9, 0x4, 0x2, 0x2, 0x39, 0x38, 0x3, 0x2, 0x2, 0x2, 0x3a, 0x3b, 0x3,
|
||||
0x2, 0x2, 0x2, 0x3b, 0x39, 0x3, 0x2, 0x2, 0x2, 0x3b, 0x3c, 0x3, 0x2,
|
||||
0x2, 0x2, 0x3c, 0xe, 0x3, 0x2, 0x2, 0x2, 0x3d, 0x3e, 0x7, 0x41, 0x2,
|
||||
0x2, 0x3e, 0x10, 0x3, 0x2, 0x2, 0x2, 0x3f, 0x40, 0x7, 0x30, 0x2, 0x2,
|
||||
0x40, 0x12, 0x3, 0x2, 0x2, 0x2, 0x41, 0x42, 0x7, 0x2f, 0x2, 0x2, 0x42,
|
||||
0x14, 0x3, 0x2, 0x2, 0x2, 0x43, 0x44, 0x7, 0x2d, 0x2, 0x2, 0x44, 0x16,
|
||||
0x3, 0x2, 0x2, 0x2, 0x45, 0x46, 0x7, 0x40, 0x2, 0x2, 0x46, 0x18, 0x3,
|
||||
0x2, 0x2, 0x2, 0x47, 0x48, 0x7, 0x3e, 0x2, 0x2, 0x48, 0x1a, 0x3, 0x2,
|
||||
0x2, 0x2, 0x7, 0x2, 0x25, 0x29, 0x2c, 0x3b, 0x4, 0x8, 0x2, 0x2, 0x2,
|
||||
0x3, 0x2,
|
||||
};
|
||||
|
||||
atn::ATNDeserializer deserializer;
|
||||
_atn = deserializer.deserialize(_serializedATN);
|
||||
|
||||
size_t count = _atn.getNumberOfDecisions();
|
||||
_decisionToDFA.reserve(count);
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
_decisionToDFA.emplace_back(_atn.getDecisionState(i), i);
|
||||
}
|
||||
}
|
||||
|
||||
bfLexer::Initializer bfLexer::_init;
|
@@ -1,57 +0,0 @@
|
||||
|
||||
// Generated from /home/atreya/Documents/Projects/Miscellaneous/bfc/grammar/bf.g4 by ANTLR 4.8
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "antlr4-runtime.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class bfLexer : public antlr4::Lexer {
|
||||
public:
|
||||
enum {
|
||||
NEWLINE = 1, COMMENT = 2, WS = 3, LOOPSTART = 4, LOOPEND = 5, NUMBER = 6,
|
||||
INPUT = 7, OUTPUT = 8, DEC = 9, INC = 10, LEFT = 11, RIGHT = 12
|
||||
};
|
||||
|
||||
bfLexer(antlr4::CharStream *input);
|
||||
~bfLexer();
|
||||
|
||||
virtual std::string getGrammarFileName() const override;
|
||||
virtual const std::vector<std::string>& getRuleNames() const override;
|
||||
|
||||
virtual const std::vector<std::string>& getChannelNames() const override;
|
||||
virtual const std::vector<std::string>& getModeNames() const override;
|
||||
virtual const std::vector<std::string>& getTokenNames() const override; // deprecated, use vocabulary instead
|
||||
virtual antlr4::dfa::Vocabulary& getVocabulary() const override;
|
||||
|
||||
virtual const std::vector<uint16_t> getSerializedATN() const override;
|
||||
virtual const antlr4::atn::ATN& getATN() const override;
|
||||
|
||||
private:
|
||||
static std::vector<antlr4::dfa::DFA> _decisionToDFA;
|
||||
static antlr4::atn::PredictionContextCache _sharedContextCache;
|
||||
static std::vector<std::string> _ruleNames;
|
||||
static std::vector<std::string> _tokenNames;
|
||||
static std::vector<std::string> _channelNames;
|
||||
static std::vector<std::string> _modeNames;
|
||||
|
||||
static std::vector<std::string> _literalNames;
|
||||
static std::vector<std::string> _symbolicNames;
|
||||
static antlr4::dfa::Vocabulary _vocabulary;
|
||||
static antlr4::atn::ATN _atn;
|
||||
static std::vector<uint16_t> _serializedATN;
|
||||
|
||||
|
||||
// Individual action functions triggered by action() above.
|
||||
|
||||
// Individual semantic predicate functions triggered by sempred() above.
|
||||
|
||||
struct Initializer {
|
||||
Initializer();
|
||||
};
|
||||
static Initializer _init;
|
||||
};
|
||||
|
@@ -1,21 +0,0 @@
|
||||
NEWLINE=1
|
||||
COMMENT=2
|
||||
WS=3
|
||||
LOOPSTART=4
|
||||
LOOPEND=5
|
||||
NUMBER=6
|
||||
INPUT=7
|
||||
OUTPUT=8
|
||||
DEC=9
|
||||
INC=10
|
||||
LEFT=11
|
||||
RIGHT=12
|
||||
'\n'=1
|
||||
'['=4
|
||||
']'=5
|
||||
'?'=7
|
||||
'.'=8
|
||||
'-'=9
|
||||
'+'=10
|
||||
'>'=11
|
||||
'<'=12
|
@@ -1,7 +0,0 @@
|
||||
|
||||
// Generated from /home/atreya/Documents/Projects/Miscellaneous/bfc/grammar/bf.g4 by ANTLR 4.8
|
||||
|
||||
|
||||
#include "bfListener.h"
|
||||
|
||||
|
@@ -1,40 +0,0 @@
|
||||
|
||||
// Generated from /home/atreya/Documents/Projects/Miscellaneous/bfc/grammar/bf.g4 by ANTLR 4.8
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "antlr4-runtime.h"
|
||||
#include "bfParser.h"
|
||||
|
||||
|
||||
/**
|
||||
* This interface defines an abstract listener for a parse tree produced by bfParser.
|
||||
*/
|
||||
class bfListener : public antlr4::tree::ParseTreeListener {
|
||||
public:
|
||||
|
||||
virtual void enterProgram(bfParser::ProgramContext *ctx) = 0;
|
||||
virtual void exitProgram(bfParser::ProgramContext *ctx) = 0;
|
||||
|
||||
virtual void enterStatements(bfParser::StatementsContext *ctx) = 0;
|
||||
virtual void exitStatements(bfParser::StatementsContext *ctx) = 0;
|
||||
|
||||
virtual void enterLoopStmt(bfParser::LoopStmtContext *ctx) = 0;
|
||||
virtual void exitLoopStmt(bfParser::LoopStmtContext *ctx) = 0;
|
||||
|
||||
virtual void enterNumberedStatement(bfParser::NumberedStatementContext *ctx) = 0;
|
||||
virtual void exitNumberedStatement(bfParser::NumberedStatementContext *ctx) = 0;
|
||||
|
||||
virtual void enterStatement(bfParser::StatementContext *ctx) = 0;
|
||||
virtual void exitStatement(bfParser::StatementContext *ctx) = 0;
|
||||
|
||||
virtual void enterInputStmt(bfParser::InputStmtContext *ctx) = 0;
|
||||
virtual void exitInputStmt(bfParser::InputStmtContext *ctx) = 0;
|
||||
|
||||
virtual void enterOutputStmt(bfParser::OutputStmtContext *ctx) = 0;
|
||||
virtual void exitOutputStmt(bfParser::OutputStmtContext *ctx) = 0;
|
||||
|
||||
|
||||
};
|
||||
|
@@ -1,687 +0,0 @@
|
||||
|
||||
// Generated from /home/atreya/Documents/Projects/Miscellaneous/bfc/grammar/bf.g4 by ANTLR 4.8
|
||||
|
||||
|
||||
#include "bfListener.h"
|
||||
#include "bfVisitor.h"
|
||||
|
||||
#include "bfParser.h"
|
||||
|
||||
|
||||
using namespace antlrcpp;
|
||||
using namespace antlr4;
|
||||
|
||||
bfParser::bfParser(TokenStream *input) : Parser(input) {
|
||||
_interpreter = new atn::ParserATNSimulator(this, _atn, _decisionToDFA, _sharedContextCache);
|
||||
}
|
||||
|
||||
bfParser::~bfParser() {
|
||||
delete _interpreter;
|
||||
}
|
||||
|
||||
std::string bfParser::getGrammarFileName() const {
|
||||
return "bf.g4";
|
||||
}
|
||||
|
||||
const std::vector<std::string>& bfParser::getRuleNames() const {
|
||||
return _ruleNames;
|
||||
}
|
||||
|
||||
dfa::Vocabulary& bfParser::getVocabulary() const {
|
||||
return _vocabulary;
|
||||
}
|
||||
|
||||
|
||||
//----------------- ProgramContext ------------------------------------------------------------------
|
||||
|
||||
bfParser::ProgramContext::ProgramContext(ParserRuleContext *parent, size_t invokingState)
|
||||
: ParserRuleContext(parent, invokingState) {
|
||||
}
|
||||
|
||||
tree::TerminalNode* bfParser::ProgramContext::EOF() {
|
||||
return getToken(bfParser::EOF, 0);
|
||||
}
|
||||
|
||||
std::vector<bfParser::StatementsContext *> bfParser::ProgramContext::statements() {
|
||||
return getRuleContexts<bfParser::StatementsContext>();
|
||||
}
|
||||
|
||||
bfParser::StatementsContext* bfParser::ProgramContext::statements(size_t i) {
|
||||
return getRuleContext<bfParser::StatementsContext>(i);
|
||||
}
|
||||
|
||||
|
||||
size_t bfParser::ProgramContext::getRuleIndex() const {
|
||||
return bfParser::RuleProgram;
|
||||
}
|
||||
|
||||
void bfParser::ProgramContext::enterRule(tree::ParseTreeListener *listener) {
|
||||
auto parserListener = dynamic_cast<bfListener *>(listener);
|
||||
if (parserListener != nullptr)
|
||||
parserListener->enterProgram(this);
|
||||
}
|
||||
|
||||
void bfParser::ProgramContext::exitRule(tree::ParseTreeListener *listener) {
|
||||
auto parserListener = dynamic_cast<bfListener *>(listener);
|
||||
if (parserListener != nullptr)
|
||||
parserListener->exitProgram(this);
|
||||
}
|
||||
|
||||
|
||||
antlrcpp::Any bfParser::ProgramContext::accept(tree::ParseTreeVisitor *visitor) {
|
||||
if (auto parserVisitor = dynamic_cast<bfVisitor*>(visitor))
|
||||
return parserVisitor->visitProgram(this);
|
||||
else
|
||||
return visitor->visitChildren(this);
|
||||
}
|
||||
|
||||
bfParser::ProgramContext* bfParser::program() {
|
||||
ProgramContext *_localctx = _tracker.createInstance<ProgramContext>(_ctx, getState());
|
||||
enterRule(_localctx, 0, bfParser::RuleProgram);
|
||||
size_t _la = 0;
|
||||
|
||||
auto onExit = finally([=] {
|
||||
exitRule();
|
||||
});
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
setState(17);
|
||||
_errHandler->sync(this);
|
||||
_la = _input->LA(1);
|
||||
while ((((_la & ~ 0x3fULL) == 0) &&
|
||||
((1ULL << _la) & ((1ULL << bfParser::LOOPSTART)
|
||||
| (1ULL << bfParser::INPUT)
|
||||
| (1ULL << bfParser::OUTPUT)
|
||||
| (1ULL << bfParser::DEC)
|
||||
| (1ULL << bfParser::INC)
|
||||
| (1ULL << bfParser::LEFT)
|
||||
| (1ULL << bfParser::RIGHT))) != 0)) {
|
||||
setState(14);
|
||||
statements();
|
||||
setState(19);
|
||||
_errHandler->sync(this);
|
||||
_la = _input->LA(1);
|
||||
}
|
||||
setState(20);
|
||||
match(bfParser::EOF);
|
||||
|
||||
}
|
||||
catch (RecognitionException &e) {
|
||||
_errHandler->reportError(this, e);
|
||||
_localctx->exception = std::current_exception();
|
||||
_errHandler->recover(this, _localctx->exception);
|
||||
}
|
||||
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
//----------------- StatementsContext ------------------------------------------------------------------
|
||||
|
||||
bfParser::StatementsContext::StatementsContext(ParserRuleContext *parent, size_t invokingState)
|
||||
: ParserRuleContext(parent, invokingState) {
|
||||
}
|
||||
|
||||
std::vector<bfParser::StatementContext *> bfParser::StatementsContext::statement() {
|
||||
return getRuleContexts<bfParser::StatementContext>();
|
||||
}
|
||||
|
||||
bfParser::StatementContext* bfParser::StatementsContext::statement(size_t i) {
|
||||
return getRuleContext<bfParser::StatementContext>(i);
|
||||
}
|
||||
|
||||
std::vector<bfParser::NumberedStatementContext *> bfParser::StatementsContext::numberedStatement() {
|
||||
return getRuleContexts<bfParser::NumberedStatementContext>();
|
||||
}
|
||||
|
||||
bfParser::NumberedStatementContext* bfParser::StatementsContext::numberedStatement(size_t i) {
|
||||
return getRuleContext<bfParser::NumberedStatementContext>(i);
|
||||
}
|
||||
|
||||
std::vector<bfParser::LoopStmtContext *> bfParser::StatementsContext::loopStmt() {
|
||||
return getRuleContexts<bfParser::LoopStmtContext>();
|
||||
}
|
||||
|
||||
bfParser::LoopStmtContext* bfParser::StatementsContext::loopStmt(size_t i) {
|
||||
return getRuleContext<bfParser::LoopStmtContext>(i);
|
||||
}
|
||||
|
||||
|
||||
size_t bfParser::StatementsContext::getRuleIndex() const {
|
||||
return bfParser::RuleStatements;
|
||||
}
|
||||
|
||||
void bfParser::StatementsContext::enterRule(tree::ParseTreeListener *listener) {
|
||||
auto parserListener = dynamic_cast<bfListener *>(listener);
|
||||
if (parserListener != nullptr)
|
||||
parserListener->enterStatements(this);
|
||||
}
|
||||
|
||||
void bfParser::StatementsContext::exitRule(tree::ParseTreeListener *listener) {
|
||||
auto parserListener = dynamic_cast<bfListener *>(listener);
|
||||
if (parserListener != nullptr)
|
||||
parserListener->exitStatements(this);
|
||||
}
|
||||
|
||||
|
||||
antlrcpp::Any bfParser::StatementsContext::accept(tree::ParseTreeVisitor *visitor) {
|
||||
if (auto parserVisitor = dynamic_cast<bfVisitor*>(visitor))
|
||||
return parserVisitor->visitStatements(this);
|
||||
else
|
||||
return visitor->visitChildren(this);
|
||||
}
|
||||
|
||||
bfParser::StatementsContext* bfParser::statements() {
|
||||
StatementsContext *_localctx = _tracker.createInstance<StatementsContext>(_ctx, getState());
|
||||
enterRule(_localctx, 2, bfParser::RuleStatements);
|
||||
|
||||
auto onExit = finally([=] {
|
||||
exitRule();
|
||||
});
|
||||
try {
|
||||
size_t alt;
|
||||
enterOuterAlt(_localctx, 1);
|
||||
setState(25);
|
||||
_errHandler->sync(this);
|
||||
alt = 1;
|
||||
do {
|
||||
switch (alt) {
|
||||
case 1: {
|
||||
setState(25);
|
||||
_errHandler->sync(this);
|
||||
switch (getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 1, _ctx)) {
|
||||
case 1: {
|
||||
setState(22);
|
||||
statement();
|
||||
break;
|
||||
}
|
||||
|
||||
case 2: {
|
||||
setState(23);
|
||||
numberedStatement();
|
||||
break;
|
||||
}
|
||||
|
||||
case 3: {
|
||||
setState(24);
|
||||
loopStmt();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw NoViableAltException(this);
|
||||
}
|
||||
setState(27);
|
||||
_errHandler->sync(this);
|
||||
alt = getInterpreter<atn::ParserATNSimulator>()->adaptivePredict(_input, 2, _ctx);
|
||||
} while (alt != 2 && alt != atn::ATN::INVALID_ALT_NUMBER);
|
||||
|
||||
}
|
||||
catch (RecognitionException &e) {
|
||||
_errHandler->reportError(this, e);
|
||||
_localctx->exception = std::current_exception();
|
||||
_errHandler->recover(this, _localctx->exception);
|
||||
}
|
||||
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
//----------------- LoopStmtContext ------------------------------------------------------------------
|
||||
|
||||
bfParser::LoopStmtContext::LoopStmtContext(ParserRuleContext *parent, size_t invokingState)
|
||||
: ParserRuleContext(parent, invokingState) {
|
||||
}
|
||||
|
||||
tree::TerminalNode* bfParser::LoopStmtContext::LOOPSTART() {
|
||||
return getToken(bfParser::LOOPSTART, 0);
|
||||
}
|
||||
|
||||
bfParser::StatementsContext* bfParser::LoopStmtContext::statements() {
|
||||
return getRuleContext<bfParser::StatementsContext>(0);
|
||||
}
|
||||
|
||||
tree::TerminalNode* bfParser::LoopStmtContext::LOOPEND() {
|
||||
return getToken(bfParser::LOOPEND, 0);
|
||||
}
|
||||
|
||||
|
||||
size_t bfParser::LoopStmtContext::getRuleIndex() const {
|
||||
return bfParser::RuleLoopStmt;
|
||||
}
|
||||
|
||||
void bfParser::LoopStmtContext::enterRule(tree::ParseTreeListener *listener) {
|
||||
auto parserListener = dynamic_cast<bfListener *>(listener);
|
||||
if (parserListener != nullptr)
|
||||
parserListener->enterLoopStmt(this);
|
||||
}
|
||||
|
||||
void bfParser::LoopStmtContext::exitRule(tree::ParseTreeListener *listener) {
|
||||
auto parserListener = dynamic_cast<bfListener *>(listener);
|
||||
if (parserListener != nullptr)
|
||||
parserListener->exitLoopStmt(this);
|
||||
}
|
||||
|
||||
|
||||
antlrcpp::Any bfParser::LoopStmtContext::accept(tree::ParseTreeVisitor *visitor) {
|
||||
if (auto parserVisitor = dynamic_cast<bfVisitor*>(visitor))
|
||||
return parserVisitor->visitLoopStmt(this);
|
||||
else
|
||||
return visitor->visitChildren(this);
|
||||
}
|
||||
|
||||
bfParser::LoopStmtContext* bfParser::loopStmt() {
|
||||
LoopStmtContext *_localctx = _tracker.createInstance<LoopStmtContext>(_ctx, getState());
|
||||
enterRule(_localctx, 4, bfParser::RuleLoopStmt);
|
||||
|
||||
auto onExit = finally([=] {
|
||||
exitRule();
|
||||
});
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
setState(29);
|
||||
match(bfParser::LOOPSTART);
|
||||
setState(30);
|
||||
statements();
|
||||
setState(31);
|
||||
match(bfParser::LOOPEND);
|
||||
|
||||
}
|
||||
catch (RecognitionException &e) {
|
||||
_errHandler->reportError(this, e);
|
||||
_localctx->exception = std::current_exception();
|
||||
_errHandler->recover(this, _localctx->exception);
|
||||
}
|
||||
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
//----------------- NumberedStatementContext ------------------------------------------------------------------
|
||||
|
||||
bfParser::NumberedStatementContext::NumberedStatementContext(ParserRuleContext *parent, size_t invokingState)
|
||||
: ParserRuleContext(parent, invokingState) {
|
||||
}
|
||||
|
||||
bfParser::StatementContext* bfParser::NumberedStatementContext::statement() {
|
||||
return getRuleContext<bfParser::StatementContext>(0);
|
||||
}
|
||||
|
||||
tree::TerminalNode* bfParser::NumberedStatementContext::NUMBER() {
|
||||
return getToken(bfParser::NUMBER, 0);
|
||||
}
|
||||
|
||||
|
||||
size_t bfParser::NumberedStatementContext::getRuleIndex() const {
|
||||
return bfParser::RuleNumberedStatement;
|
||||
}
|
||||
|
||||
void bfParser::NumberedStatementContext::enterRule(tree::ParseTreeListener *listener) {
|
||||
auto parserListener = dynamic_cast<bfListener *>(listener);
|
||||
if (parserListener != nullptr)
|
||||
parserListener->enterNumberedStatement(this);
|
||||
}
|
||||
|
||||
void bfParser::NumberedStatementContext::exitRule(tree::ParseTreeListener *listener) {
|
||||
auto parserListener = dynamic_cast<bfListener *>(listener);
|
||||
if (parserListener != nullptr)
|
||||
parserListener->exitNumberedStatement(this);
|
||||
}
|
||||
|
||||
|
||||
antlrcpp::Any bfParser::NumberedStatementContext::accept(tree::ParseTreeVisitor *visitor) {
|
||||
if (auto parserVisitor = dynamic_cast<bfVisitor*>(visitor))
|
||||
return parserVisitor->visitNumberedStatement(this);
|
||||
else
|
||||
return visitor->visitChildren(this);
|
||||
}
|
||||
|
||||
bfParser::NumberedStatementContext* bfParser::numberedStatement() {
|
||||
NumberedStatementContext *_localctx = _tracker.createInstance<NumberedStatementContext>(_ctx, getState());
|
||||
enterRule(_localctx, 6, bfParser::RuleNumberedStatement);
|
||||
|
||||
auto onExit = finally([=] {
|
||||
exitRule();
|
||||
});
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
setState(33);
|
||||
statement();
|
||||
setState(34);
|
||||
match(bfParser::NUMBER);
|
||||
|
||||
}
|
||||
catch (RecognitionException &e) {
|
||||
_errHandler->reportError(this, e);
|
||||
_localctx->exception = std::current_exception();
|
||||
_errHandler->recover(this, _localctx->exception);
|
||||
}
|
||||
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
//----------------- StatementContext ------------------------------------------------------------------
|
||||
|
||||
bfParser::StatementContext::StatementContext(ParserRuleContext *parent, size_t invokingState)
|
||||
: ParserRuleContext(parent, invokingState) {
|
||||
}
|
||||
|
||||
tree::TerminalNode* bfParser::StatementContext::INC() {
|
||||
return getToken(bfParser::INC, 0);
|
||||
}
|
||||
|
||||
tree::TerminalNode* bfParser::StatementContext::DEC() {
|
||||
return getToken(bfParser::DEC, 0);
|
||||
}
|
||||
|
||||
tree::TerminalNode* bfParser::StatementContext::LEFT() {
|
||||
return getToken(bfParser::LEFT, 0);
|
||||
}
|
||||
|
||||
tree::TerminalNode* bfParser::StatementContext::RIGHT() {
|
||||
return getToken(bfParser::RIGHT, 0);
|
||||
}
|
||||
|
||||
bfParser::InputStmtContext* bfParser::StatementContext::inputStmt() {
|
||||
return getRuleContext<bfParser::InputStmtContext>(0);
|
||||
}
|
||||
|
||||
bfParser::OutputStmtContext* bfParser::StatementContext::outputStmt() {
|
||||
return getRuleContext<bfParser::OutputStmtContext>(0);
|
||||
}
|
||||
|
||||
|
||||
size_t bfParser::StatementContext::getRuleIndex() const {
|
||||
return bfParser::RuleStatement;
|
||||
}
|
||||
|
||||
void bfParser::StatementContext::enterRule(tree::ParseTreeListener *listener) {
|
||||
auto parserListener = dynamic_cast<bfListener *>(listener);
|
||||
if (parserListener != nullptr)
|
||||
parserListener->enterStatement(this);
|
||||
}
|
||||
|
||||
void bfParser::StatementContext::exitRule(tree::ParseTreeListener *listener) {
|
||||
auto parserListener = dynamic_cast<bfListener *>(listener);
|
||||
if (parserListener != nullptr)
|
||||
parserListener->exitStatement(this);
|
||||
}
|
||||
|
||||
|
||||
antlrcpp::Any bfParser::StatementContext::accept(tree::ParseTreeVisitor *visitor) {
|
||||
if (auto parserVisitor = dynamic_cast<bfVisitor*>(visitor))
|
||||
return parserVisitor->visitStatement(this);
|
||||
else
|
||||
return visitor->visitChildren(this);
|
||||
}
|
||||
|
||||
bfParser::StatementContext* bfParser::statement() {
|
||||
StatementContext *_localctx = _tracker.createInstance<StatementContext>(_ctx, getState());
|
||||
enterRule(_localctx, 8, bfParser::RuleStatement);
|
||||
|
||||
auto onExit = finally([=] {
|
||||
exitRule();
|
||||
});
|
||||
try {
|
||||
setState(42);
|
||||
_errHandler->sync(this);
|
||||
switch (_input->LA(1)) {
|
||||
case bfParser::INC: {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
setState(36);
|
||||
match(bfParser::INC);
|
||||
break;
|
||||
}
|
||||
|
||||
case bfParser::DEC: {
|
||||
enterOuterAlt(_localctx, 2);
|
||||
setState(37);
|
||||
match(bfParser::DEC);
|
||||
break;
|
||||
}
|
||||
|
||||
case bfParser::LEFT: {
|
||||
enterOuterAlt(_localctx, 3);
|
||||
setState(38);
|
||||
match(bfParser::LEFT);
|
||||
break;
|
||||
}
|
||||
|
||||
case bfParser::RIGHT: {
|
||||
enterOuterAlt(_localctx, 4);
|
||||
setState(39);
|
||||
match(bfParser::RIGHT);
|
||||
break;
|
||||
}
|
||||
|
||||
case bfParser::INPUT: {
|
||||
enterOuterAlt(_localctx, 5);
|
||||
setState(40);
|
||||
inputStmt();
|
||||
break;
|
||||
}
|
||||
|
||||
case bfParser::OUTPUT: {
|
||||
enterOuterAlt(_localctx, 6);
|
||||
setState(41);
|
||||
outputStmt();
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw NoViableAltException(this);
|
||||
}
|
||||
|
||||
}
|
||||
catch (RecognitionException &e) {
|
||||
_errHandler->reportError(this, e);
|
||||
_localctx->exception = std::current_exception();
|
||||
_errHandler->recover(this, _localctx->exception);
|
||||
}
|
||||
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
//----------------- InputStmtContext ------------------------------------------------------------------
|
||||
|
||||
bfParser::InputStmtContext::InputStmtContext(ParserRuleContext *parent, size_t invokingState)
|
||||
: ParserRuleContext(parent, invokingState) {
|
||||
}
|
||||
|
||||
tree::TerminalNode* bfParser::InputStmtContext::INPUT() {
|
||||
return getToken(bfParser::INPUT, 0);
|
||||
}
|
||||
|
||||
|
||||
size_t bfParser::InputStmtContext::getRuleIndex() const {
|
||||
return bfParser::RuleInputStmt;
|
||||
}
|
||||
|
||||
void bfParser::InputStmtContext::enterRule(tree::ParseTreeListener *listener) {
|
||||
auto parserListener = dynamic_cast<bfListener *>(listener);
|
||||
if (parserListener != nullptr)
|
||||
parserListener->enterInputStmt(this);
|
||||
}
|
||||
|
||||
void bfParser::InputStmtContext::exitRule(tree::ParseTreeListener *listener) {
|
||||
auto parserListener = dynamic_cast<bfListener *>(listener);
|
||||
if (parserListener != nullptr)
|
||||
parserListener->exitInputStmt(this);
|
||||
}
|
||||
|
||||
|
||||
antlrcpp::Any bfParser::InputStmtContext::accept(tree::ParseTreeVisitor *visitor) {
|
||||
if (auto parserVisitor = dynamic_cast<bfVisitor*>(visitor))
|
||||
return parserVisitor->visitInputStmt(this);
|
||||
else
|
||||
return visitor->visitChildren(this);
|
||||
}
|
||||
|
||||
bfParser::InputStmtContext* bfParser::inputStmt() {
|
||||
InputStmtContext *_localctx = _tracker.createInstance<InputStmtContext>(_ctx, getState());
|
||||
enterRule(_localctx, 10, bfParser::RuleInputStmt);
|
||||
|
||||
auto onExit = finally([=] {
|
||||
exitRule();
|
||||
});
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
setState(44);
|
||||
match(bfParser::INPUT);
|
||||
|
||||
}
|
||||
catch (RecognitionException &e) {
|
||||
_errHandler->reportError(this, e);
|
||||
_localctx->exception = std::current_exception();
|
||||
_errHandler->recover(this, _localctx->exception);
|
||||
}
|
||||
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
//----------------- OutputStmtContext ------------------------------------------------------------------
|
||||
|
||||
bfParser::OutputStmtContext::OutputStmtContext(ParserRuleContext *parent, size_t invokingState)
|
||||
: ParserRuleContext(parent, invokingState) {
|
||||
}
|
||||
|
||||
tree::TerminalNode* bfParser::OutputStmtContext::OUTPUT() {
|
||||
return getToken(bfParser::OUTPUT, 0);
|
||||
}
|
||||
|
||||
|
||||
size_t bfParser::OutputStmtContext::getRuleIndex() const {
|
||||
return bfParser::RuleOutputStmt;
|
||||
}
|
||||
|
||||
void bfParser::OutputStmtContext::enterRule(tree::ParseTreeListener *listener) {
|
||||
auto parserListener = dynamic_cast<bfListener *>(listener);
|
||||
if (parserListener != nullptr)
|
||||
parserListener->enterOutputStmt(this);
|
||||
}
|
||||
|
||||
void bfParser::OutputStmtContext::exitRule(tree::ParseTreeListener *listener) {
|
||||
auto parserListener = dynamic_cast<bfListener *>(listener);
|
||||
if (parserListener != nullptr)
|
||||
parserListener->exitOutputStmt(this);
|
||||
}
|
||||
|
||||
|
||||
antlrcpp::Any bfParser::OutputStmtContext::accept(tree::ParseTreeVisitor *visitor) {
|
||||
if (auto parserVisitor = dynamic_cast<bfVisitor*>(visitor))
|
||||
return parserVisitor->visitOutputStmt(this);
|
||||
else
|
||||
return visitor->visitChildren(this);
|
||||
}
|
||||
|
||||
bfParser::OutputStmtContext* bfParser::outputStmt() {
|
||||
OutputStmtContext *_localctx = _tracker.createInstance<OutputStmtContext>(_ctx, getState());
|
||||
enterRule(_localctx, 12, bfParser::RuleOutputStmt);
|
||||
|
||||
auto onExit = finally([=] {
|
||||
exitRule();
|
||||
});
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
setState(46);
|
||||
match(bfParser::OUTPUT);
|
||||
|
||||
}
|
||||
catch (RecognitionException &e) {
|
||||
_errHandler->reportError(this, e);
|
||||
_localctx->exception = std::current_exception();
|
||||
_errHandler->recover(this, _localctx->exception);
|
||||
}
|
||||
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
// Static vars and initialization.
|
||||
std::vector<dfa::DFA> bfParser::_decisionToDFA;
|
||||
atn::PredictionContextCache bfParser::_sharedContextCache;
|
||||
|
||||
// We own the ATN which in turn owns the ATN states.
|
||||
atn::ATN bfParser::_atn;
|
||||
std::vector<uint16_t> bfParser::_serializedATN;
|
||||
|
||||
std::vector<std::string> bfParser::_ruleNames = {
|
||||
"program", "statements", "loopStmt", "numberedStatement", "statement",
|
||||
"inputStmt", "outputStmt"
|
||||
};
|
||||
|
||||
std::vector<std::string> bfParser::_literalNames = {
|
||||
"", "'\n'", "", "", "'['", "']'", "", "'?'", "'.'", "'-'", "'+'", "'>'",
|
||||
"'<'"
|
||||
};
|
||||
|
||||
std::vector<std::string> bfParser::_symbolicNames = {
|
||||
"", "NEWLINE", "COMMENT", "WS", "LOOPSTART", "LOOPEND", "NUMBER", "INPUT",
|
||||
"OUTPUT", "DEC", "INC", "LEFT", "RIGHT"
|
||||
};
|
||||
|
||||
dfa::Vocabulary bfParser::_vocabulary(_literalNames, _symbolicNames);
|
||||
|
||||
std::vector<std::string> bfParser::_tokenNames;
|
||||
|
||||
bfParser::Initializer::Initializer() {
|
||||
for (size_t i = 0; i < _symbolicNames.size(); ++i) {
|
||||
std::string name = _vocabulary.getLiteralName(i);
|
||||
if (name.empty()) {
|
||||
name = _vocabulary.getSymbolicName(i);
|
||||
}
|
||||
|
||||
if (name.empty()) {
|
||||
_tokenNames.push_back("<INVALID>");
|
||||
} else {
|
||||
_tokenNames.push_back(name);
|
||||
}
|
||||
}
|
||||
|
||||
_serializedATN = {
|
||||
0x3, 0x608b, 0xa72a, 0x8133, 0xb9ed, 0x417c, 0x3be7, 0x7786, 0x5964,
|
||||
0x3, 0xe, 0x33, 0x4, 0x2, 0x9, 0x2, 0x4, 0x3, 0x9, 0x3, 0x4, 0x4, 0x9,
|
||||
0x4, 0x4,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, 0x2d, 0xb, 0x3, 0x2, 0x2, 0x2, 0x2e, 0x2f, 0x7, 0x9, 0x2,
|
||||
0x2, 0x2f, 0xd, 0x3, 0x2, 0x2, 0x2, 0x30, 0x31, 0x7, 0xa, 0x2, 0x2,
|
||||
0x31, 0xf, 0x3, 0x2, 0x2, 0x2, 0x6, 0x13, 0x1b, 0x1d, 0x2c,
|
||||
};
|
||||
|
||||
atn::ATNDeserializer deserializer;
|
||||
_atn = deserializer.deserialize(_serializedATN);
|
||||
|
||||
size_t count = _atn.getNumberOfDecisions();
|
||||
_decisionToDFA.reserve(count);
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
_decisionToDFA.emplace_back(_atn.getDecisionState(i), i);
|
||||
}
|
||||
}
|
||||
|
||||
bfParser::Initializer bfParser::_init;
|
@@ -1,181 +0,0 @@
|
||||
|
||||
// Generated from /home/atreya/Documents/Projects/Miscellaneous/bfc/grammar/bf.g4 by ANTLR 4.8
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "antlr4-runtime.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class bfParser : public antlr4::Parser {
|
||||
public:
|
||||
enum {
|
||||
NEWLINE = 1, COMMENT = 2, WS = 3, LOOPSTART = 4, LOOPEND = 5, NUMBER = 6,
|
||||
INPUT = 7, OUTPUT = 8, DEC = 9, INC = 10, LEFT = 11, RIGHT = 12
|
||||
};
|
||||
|
||||
enum {
|
||||
RuleProgram = 0, RuleStatements = 1, RuleLoopStmt = 2, RuleNumberedStatement = 3,
|
||||
RuleStatement = 4, RuleInputStmt = 5, RuleOutputStmt = 6
|
||||
};
|
||||
|
||||
bfParser(antlr4::TokenStream *input);
|
||||
~bfParser();
|
||||
|
||||
virtual std::string getGrammarFileName() const override;
|
||||
virtual const antlr4::atn::ATN& getATN() const override { return _atn; };
|
||||
virtual const std::vector<std::string>& getTokenNames() const override { return _tokenNames; }; // deprecated: use vocabulary instead.
|
||||
virtual const std::vector<std::string>& getRuleNames() const override;
|
||||
virtual antlr4::dfa::Vocabulary& getVocabulary() const override;
|
||||
|
||||
|
||||
class ProgramContext;
|
||||
class StatementsContext;
|
||||
class LoopStmtContext;
|
||||
class NumberedStatementContext;
|
||||
class StatementContext;
|
||||
class InputStmtContext;
|
||||
class OutputStmtContext;
|
||||
|
||||
class ProgramContext : public antlr4::ParserRuleContext {
|
||||
public:
|
||||
ProgramContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||
virtual size_t getRuleIndex() const override;
|
||||
antlr4::tree::TerminalNode *EOF();
|
||||
std::vector<StatementsContext *> statements();
|
||||
StatementsContext* statements(size_t i);
|
||||
|
||||
virtual void enterRule(antlr4::tree::ParseTreeListener *listener) override;
|
||||
virtual void exitRule(antlr4::tree::ParseTreeListener *listener) override;
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
|
||||
};
|
||||
|
||||
ProgramContext* program();
|
||||
|
||||
class StatementsContext : public antlr4::ParserRuleContext {
|
||||
public:
|
||||
StatementsContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||
virtual size_t getRuleIndex() const override;
|
||||
std::vector<StatementContext *> statement();
|
||||
StatementContext* statement(size_t i);
|
||||
std::vector<NumberedStatementContext *> numberedStatement();
|
||||
NumberedStatementContext* numberedStatement(size_t i);
|
||||
std::vector<LoopStmtContext *> loopStmt();
|
||||
LoopStmtContext* loopStmt(size_t i);
|
||||
|
||||
virtual void enterRule(antlr4::tree::ParseTreeListener *listener) override;
|
||||
virtual void exitRule(antlr4::tree::ParseTreeListener *listener) override;
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
|
||||
};
|
||||
|
||||
StatementsContext* statements();
|
||||
|
||||
class LoopStmtContext : public antlr4::ParserRuleContext {
|
||||
public:
|
||||
LoopStmtContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||
virtual size_t getRuleIndex() const override;
|
||||
antlr4::tree::TerminalNode *LOOPSTART();
|
||||
StatementsContext *statements();
|
||||
antlr4::tree::TerminalNode *LOOPEND();
|
||||
|
||||
virtual void enterRule(antlr4::tree::ParseTreeListener *listener) override;
|
||||
virtual void exitRule(antlr4::tree::ParseTreeListener *listener) override;
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
|
||||
};
|
||||
|
||||
LoopStmtContext* loopStmt();
|
||||
|
||||
class NumberedStatementContext : public antlr4::ParserRuleContext {
|
||||
public:
|
||||
NumberedStatementContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||
virtual size_t getRuleIndex() const override;
|
||||
StatementContext *statement();
|
||||
antlr4::tree::TerminalNode *NUMBER();
|
||||
|
||||
virtual void enterRule(antlr4::tree::ParseTreeListener *listener) override;
|
||||
virtual void exitRule(antlr4::tree::ParseTreeListener *listener) override;
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
|
||||
};
|
||||
|
||||
NumberedStatementContext* numberedStatement();
|
||||
|
||||
class StatementContext : public antlr4::ParserRuleContext {
|
||||
public:
|
||||
StatementContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||
virtual size_t getRuleIndex() const override;
|
||||
antlr4::tree::TerminalNode *INC();
|
||||
antlr4::tree::TerminalNode *DEC();
|
||||
antlr4::tree::TerminalNode *LEFT();
|
||||
antlr4::tree::TerminalNode *RIGHT();
|
||||
InputStmtContext *inputStmt();
|
||||
OutputStmtContext *outputStmt();
|
||||
|
||||
virtual void enterRule(antlr4::tree::ParseTreeListener *listener) override;
|
||||
virtual void exitRule(antlr4::tree::ParseTreeListener *listener) override;
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
|
||||
};
|
||||
|
||||
StatementContext* statement();
|
||||
|
||||
class InputStmtContext : public antlr4::ParserRuleContext {
|
||||
public:
|
||||
InputStmtContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||
virtual size_t getRuleIndex() const override;
|
||||
antlr4::tree::TerminalNode *INPUT();
|
||||
|
||||
virtual void enterRule(antlr4::tree::ParseTreeListener *listener) override;
|
||||
virtual void exitRule(antlr4::tree::ParseTreeListener *listener) override;
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
|
||||
};
|
||||
|
||||
InputStmtContext* inputStmt();
|
||||
|
||||
class OutputStmtContext : public antlr4::ParserRuleContext {
|
||||
public:
|
||||
OutputStmtContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||
virtual size_t getRuleIndex() const override;
|
||||
antlr4::tree::TerminalNode *OUTPUT();
|
||||
|
||||
virtual void enterRule(antlr4::tree::ParseTreeListener *listener) override;
|
||||
virtual void exitRule(antlr4::tree::ParseTreeListener *listener) override;
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
|
||||
};
|
||||
|
||||
OutputStmtContext* outputStmt();
|
||||
|
||||
|
||||
private:
|
||||
static std::vector<antlr4::dfa::DFA> _decisionToDFA;
|
||||
static antlr4::atn::PredictionContextCache _sharedContextCache;
|
||||
static std::vector<std::string> _ruleNames;
|
||||
static std::vector<std::string> _tokenNames;
|
||||
|
||||
static std::vector<std::string> _literalNames;
|
||||
static std::vector<std::string> _symbolicNames;
|
||||
static antlr4::dfa::Vocabulary _vocabulary;
|
||||
static antlr4::atn::ATN _atn;
|
||||
static std::vector<uint16_t> _serializedATN;
|
||||
|
||||
|
||||
struct Initializer {
|
||||
Initializer();
|
||||
};
|
||||
static Initializer _init;
|
||||
};
|
||||
|
@@ -1,7 +0,0 @@
|
||||
|
||||
// Generated from /home/atreya/Documents/Projects/Miscellaneous/bfc/grammar/bf.g4 by ANTLR 4.8
|
||||
|
||||
|
||||
#include "bfVisitor.h"
|
||||
|
||||
|
@@ -1,38 +0,0 @@
|
||||
|
||||
// Generated from /home/atreya/Documents/Projects/Miscellaneous/bfc/grammar/bf.g4 by ANTLR 4.8
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "antlr4-runtime.h"
|
||||
#include "bfParser.h"
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This class defines an abstract visitor for a parse tree
|
||||
* produced by bfParser.
|
||||
*/
|
||||
class bfVisitor : public antlr4::tree::AbstractParseTreeVisitor {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Visit parse trees produced by bfParser.
|
||||
*/
|
||||
virtual antlrcpp::Any visitProgram(bfParser::ProgramContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitStatements(bfParser::StatementsContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitLoopStmt(bfParser::LoopStmtContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitNumberedStatement(bfParser::NumberedStatementContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitStatement(bfParser::StatementContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitInputStmt(bfParser::InputStmtContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitOutputStmt(bfParser::OutputStmtContext *context) = 0;
|
||||
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user