Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
9f3af7ac5f | |||
4b7b386672 | |||
ae57a1bcf2 | |||
88109924ed | |||
f11f844ef5 | |||
b38a794465 |
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
lib/generated/* linguist-generated
|
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,6 +1,6 @@
|
|||||||
.antlr/
|
.antlr/
|
||||||
build/
|
build/
|
||||||
lib/
|
# lib/
|
||||||
# Prerequisites
|
# Prerequisites
|
||||||
thirdparty/antlr/*.jar
|
thirdparty/antlr/*.jar
|
||||||
*.d
|
*.d
|
||||||
|
20
.vscode/c_cpp_properties.json
vendored
20
.vscode/c_cpp_properties.json
vendored
@@ -1,20 +0,0 @@
|
|||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Linux",
|
|
||||||
"includePath": [
|
|
||||||
"${workspaceFolder}/include",
|
|
||||||
"${workspaceFolder}/lib/antlr4/include",
|
|
||||||
"${workspaceFolder}/lib/cxxopts/include",
|
|
||||||
"${workspaceFolder}/lib/generated"
|
|
||||||
],
|
|
||||||
"defines": [],
|
|
||||||
"compilerPath": "/usr/lib64/ccache/clang",
|
|
||||||
"cStandard": "c11",
|
|
||||||
"cppStandard": "c++11",
|
|
||||||
"intelliSenseMode": "clang-x64",
|
|
||||||
"configurationProvider": "ms-vscode.cmake-tools"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"version": 4
|
|
||||||
}
|
|
@@ -21,13 +21,13 @@ set(SOURCES
|
|||||||
)
|
)
|
||||||
add_executable(main.out ${SOURCES})
|
add_executable(main.out ${SOURCES})
|
||||||
|
|
||||||
target_link_libraries(main.out ${PROJECT_SOURCE_DIR}/lib/antlr4/lib/libantlr4-runtime.a)
|
target_link_libraries(main.out libantlr4-runtime.so)
|
||||||
|
# target_link_libraries(main.out ${PROJECT_SOURCE_DIR}/lib/antlr4/lib/libantlr4-runtime.a)
|
||||||
|
|
||||||
target_include_directories(main.out
|
target_include_directories(main.out
|
||||||
PUBLIC
|
PUBLIC
|
||||||
${PROJECT_SOURCE_DIR}/lib/generated
|
${PROJECT_SOURCE_DIR}/lib/generated
|
||||||
${PROJECT_SOURCE_DIR}/include
|
${PROJECT_SOURCE_DIR}/include
|
||||||
${PROJECT_SOURCE_DIR}/lib/antlr4/include
|
|
||||||
${PROJECT_SOURCE_DIR}/lib/cxxopts/include
|
${PROJECT_SOURCE_DIR}/lib/cxxopts/include
|
||||||
|
/usr/include/antlr4-runtime
|
||||||
)
|
)
|
||||||
|
@@ -4,7 +4,7 @@ A slight syntactic superset of BF.
|
|||||||
|
|
||||||
Development requirements:
|
Development requirements:
|
||||||
1. cxxopts -> v2.2.1
|
1. cxxopts -> v2.2.1
|
||||||
2. antlr4
|
2. antlr4 -> v4
|
||||||
|
|
||||||
|
|
||||||
*HelloWorld.bfe*
|
*HelloWorld.bfe*
|
||||||
@@ -61,15 +61,14 @@ Eg.
|
|||||||
|
|
||||||
## Setup oddities (dev)
|
## Setup oddities (dev)
|
||||||
|
|
||||||
1. Copy antlr4's cpp libs to `./libs/antlr4`. (Please take care that the include folder points straight to the files not to `antlr-runtime`)
|
1. Generate parsers to `./libs/generated` or use VSCode with the ANTLR extension or use a downloaded ANTLR JAR.
|
||||||
2. Copy `antlr-4.8-complete.jar` to `./thirdparty/antlr`.
|
|
||||||
3. Generate parsers to `./libs/generated` or use VSCode with the ANTLR extension.
|
|
||||||
|
|
||||||
## Todo (Tentative)
|
## Todo (Tentative)
|
||||||
|
|
||||||
- [ ] Grammar
|
- [ ] Grammar
|
||||||
- [X] Number shorthand
|
- [X] Number shorthand
|
||||||
- [X] Loop statements
|
- [X] Loop statements
|
||||||
|
- [X] Ignore rest
|
||||||
- [ ] Shorthand segments
|
- [ ] Shorthand segments
|
||||||
- [X] Processing
|
- [X] Processing
|
||||||
- [X] Translate to bf
|
- [X] Translate to bf
|
||||||
|
@@ -68,7 +68,6 @@ outputStmt
|
|||||||
NEWLINE: '\n' -> skip;
|
NEWLINE: '\n' -> skip;
|
||||||
COMMENT: '//' ~[\r\n]* '\r'? '\n'? -> channel(HIDDEN);
|
COMMENT: '//' ~[\r\n]* '\r'? '\n'? -> channel(HIDDEN);
|
||||||
ML_COMMENT: '/*' .*? '*/' ->channel(HIDDEN);
|
ML_COMMENT: '/*' .*? '*/' ->channel(HIDDEN);
|
||||||
WS: [ \r\n] -> skip;
|
|
||||||
DEF: '#';
|
DEF: '#';
|
||||||
LOOPSTART: '[';
|
LOOPSTART: '[';
|
||||||
LOOPEND:']';
|
LOOPEND:']';
|
||||||
@@ -81,3 +80,6 @@ DEC: '-';
|
|||||||
INC: '+';
|
INC: '+';
|
||||||
LEFT: '<';
|
LEFT: '<';
|
||||||
RIGHT: '>';
|
RIGHT: '>';
|
||||||
|
EVERYTHING_ELSE: . ->channel(HIDDEN);
|
||||||
|
WS: [ \r\n] -> skip;
|
||||||
|
|
||||||
|
2383
lib/cxxopts/include/cxxopts.hpp
Normal file
2383
lib/cxxopts/include/cxxopts.hpp
Normal file
File diff suppressed because it is too large
Load Diff
29
lib/generated/bfe.tokens
generated
Normal file
29
lib/generated/bfe.tokens
generated
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
NEWLINE=1
|
||||||
|
COMMENT=2
|
||||||
|
ML_COMMENT=3
|
||||||
|
DEF=4
|
||||||
|
LOOPSTART=5
|
||||||
|
LOOPEND=6
|
||||||
|
GRPSTART=7
|
||||||
|
GRPEND=8
|
||||||
|
NUMBER=9
|
||||||
|
INPUT=10
|
||||||
|
OUTPUT=11
|
||||||
|
DEC=12
|
||||||
|
INC=13
|
||||||
|
LEFT=14
|
||||||
|
RIGHT=15
|
||||||
|
EVERYTHING_ELSE=16
|
||||||
|
WS=17
|
||||||
|
'\n'=1
|
||||||
|
'#'=4
|
||||||
|
'['=5
|
||||||
|
']'=6
|
||||||
|
'('=7
|
||||||
|
')'=8
|
||||||
|
','=10
|
||||||
|
'.'=11
|
||||||
|
'-'=12
|
||||||
|
'+'=13
|
||||||
|
'<'=14
|
||||||
|
'>'=15
|
7
lib/generated/bfeBaseListener.cpp
generated
Normal file
7
lib/generated/bfeBaseListener.cpp
generated
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
// Generated from /home/atreya/Documents/Projects/Miscellaneous/bfc/grammar/bfe.g4 by ANTLR 4.8
|
||||||
|
|
||||||
|
|
||||||
|
#include "bfeBaseListener.h"
|
||||||
|
|
||||||
|
|
68
lib/generated/bfeBaseListener.h
generated
Normal file
68
lib/generated/bfeBaseListener.h
generated
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
|
||||||
|
// Generated from /home/atreya/Documents/Projects/Miscellaneous/bfc/grammar/bfe.g4 by ANTLR 4.8
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
#include "antlr4-runtime.h"
|
||||||
|
#include "bfeListener.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class provides an empty implementation of bfeListener,
|
||||||
|
* which can be extended to create a listener which only needs to handle a subset
|
||||||
|
* of the available methods.
|
||||||
|
*/
|
||||||
|
class bfeBaseListener : public bfeListener {
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void enterProgram(bfeParser::ProgramContext * /*ctx*/) override { }
|
||||||
|
virtual void exitProgram(bfeParser::ProgramContext * /*ctx*/) override { }
|
||||||
|
|
||||||
|
virtual void enterStatements(bfeParser::StatementsContext * /*ctx*/) override { }
|
||||||
|
virtual void exitStatements(bfeParser::StatementsContext * /*ctx*/) override { }
|
||||||
|
|
||||||
|
virtual void enterEligibleStmt(bfeParser::EligibleStmtContext * /*ctx*/) override { }
|
||||||
|
virtual void exitEligibleStmt(bfeParser::EligibleStmtContext * /*ctx*/) override { }
|
||||||
|
|
||||||
|
virtual void enterNumberedStmt(bfeParser::NumberedStmtContext * /*ctx*/) override { }
|
||||||
|
virtual void exitNumberedStmt(bfeParser::NumberedStmtContext * /*ctx*/) override { }
|
||||||
|
|
||||||
|
virtual void enterStmt(bfeParser::StmtContext * /*ctx*/) override { }
|
||||||
|
virtual void exitStmt(bfeParser::StmtContext * /*ctx*/) override { }
|
||||||
|
|
||||||
|
virtual void enterGroupedStmt(bfeParser::GroupedStmtContext * /*ctx*/) override { }
|
||||||
|
virtual void exitGroupedStmt(bfeParser::GroupedStmtContext * /*ctx*/) override { }
|
||||||
|
|
||||||
|
virtual void enterLoopStmt(bfeParser::LoopStmtContext * /*ctx*/) override { }
|
||||||
|
virtual void exitLoopStmt(bfeParser::LoopStmtContext * /*ctx*/) override { }
|
||||||
|
|
||||||
|
virtual void enterBasicStmt(bfeParser::BasicStmtContext * /*ctx*/) override { }
|
||||||
|
virtual void exitBasicStmt(bfeParser::BasicStmtContext * /*ctx*/) override { }
|
||||||
|
|
||||||
|
virtual void enterPtrIncr(bfeParser::PtrIncrContext * /*ctx*/) override { }
|
||||||
|
virtual void exitPtrIncr(bfeParser::PtrIncrContext * /*ctx*/) override { }
|
||||||
|
|
||||||
|
virtual void enterPtrDecr(bfeParser::PtrDecrContext * /*ctx*/) override { }
|
||||||
|
virtual void exitPtrDecr(bfeParser::PtrDecrContext * /*ctx*/) override { }
|
||||||
|
|
||||||
|
virtual void enterPtrLeft(bfeParser::PtrLeftContext * /*ctx*/) override { }
|
||||||
|
virtual void exitPtrLeft(bfeParser::PtrLeftContext * /*ctx*/) override { }
|
||||||
|
|
||||||
|
virtual void enterPtrRight(bfeParser::PtrRightContext * /*ctx*/) override { }
|
||||||
|
virtual void exitPtrRight(bfeParser::PtrRightContext * /*ctx*/) override { }
|
||||||
|
|
||||||
|
virtual void enterInputStmt(bfeParser::InputStmtContext * /*ctx*/) override { }
|
||||||
|
virtual void exitInputStmt(bfeParser::InputStmtContext * /*ctx*/) override { }
|
||||||
|
|
||||||
|
virtual void enterOutputStmt(bfeParser::OutputStmtContext * /*ctx*/) override { }
|
||||||
|
virtual void exitOutputStmt(bfeParser::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 { }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
7
lib/generated/bfeBaseVisitor.cpp
generated
Normal file
7
lib/generated/bfeBaseVisitor.cpp
generated
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
// Generated from /home/atreya/Documents/Projects/Miscellaneous/bfc/grammar/bfe.g4 by ANTLR 4.8
|
||||||
|
|
||||||
|
|
||||||
|
#include "bfeBaseVisitor.h"
|
||||||
|
|
||||||
|
|
76
lib/generated/bfeBaseVisitor.h
generated
Normal file
76
lib/generated/bfeBaseVisitor.h
generated
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
|
||||||
|
// Generated from /home/atreya/Documents/Projects/Miscellaneous/bfc/grammar/bfe.g4 by ANTLR 4.8
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
#include "antlr4-runtime.h"
|
||||||
|
#include "bfeVisitor.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class provides an empty implementation of bfeVisitor, which can be
|
||||||
|
* extended to create a visitor which only needs to handle a subset of the available methods.
|
||||||
|
*/
|
||||||
|
class bfeBaseVisitor : public bfeVisitor {
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual antlrcpp::Any visitProgram(bfeParser::ProgramContext *ctx) override {
|
||||||
|
return visitChildren(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual antlrcpp::Any visitStatements(bfeParser::StatementsContext *ctx) override {
|
||||||
|
return visitChildren(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual antlrcpp::Any visitEligibleStmt(bfeParser::EligibleStmtContext *ctx) override {
|
||||||
|
return visitChildren(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual antlrcpp::Any visitNumberedStmt(bfeParser::NumberedStmtContext *ctx) override {
|
||||||
|
return visitChildren(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual antlrcpp::Any visitStmt(bfeParser::StmtContext *ctx) override {
|
||||||
|
return visitChildren(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual antlrcpp::Any visitGroupedStmt(bfeParser::GroupedStmtContext *ctx) override {
|
||||||
|
return visitChildren(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual antlrcpp::Any visitLoopStmt(bfeParser::LoopStmtContext *ctx) override {
|
||||||
|
return visitChildren(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual antlrcpp::Any visitBasicStmt(bfeParser::BasicStmtContext *ctx) override {
|
||||||
|
return visitChildren(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual antlrcpp::Any visitPtrIncr(bfeParser::PtrIncrContext *ctx) override {
|
||||||
|
return visitChildren(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual antlrcpp::Any visitPtrDecr(bfeParser::PtrDecrContext *ctx) override {
|
||||||
|
return visitChildren(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual antlrcpp::Any visitPtrLeft(bfeParser::PtrLeftContext *ctx) override {
|
||||||
|
return visitChildren(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual antlrcpp::Any visitPtrRight(bfeParser::PtrRightContext *ctx) override {
|
||||||
|
return visitChildren(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual antlrcpp::Any visitInputStmt(bfeParser::InputStmtContext *ctx) override {
|
||||||
|
return visitChildren(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual antlrcpp::Any visitOutputStmt(bfeParser::OutputStmtContext *ctx) override {
|
||||||
|
return visitChildren(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
192
lib/generated/bfeLexer.cpp
generated
Normal file
192
lib/generated/bfeLexer.cpp
generated
Normal file
@@ -0,0 +1,192 @@
|
|||||||
|
|
||||||
|
// Generated from /home/atreya/Documents/Projects/Miscellaneous/bfc/grammar/bfe.g4 by ANTLR 4.8
|
||||||
|
|
||||||
|
|
||||||
|
#include "bfeLexer.h"
|
||||||
|
|
||||||
|
|
||||||
|
using namespace antlr4;
|
||||||
|
|
||||||
|
|
||||||
|
bfeLexer::bfeLexer(CharStream *input) : Lexer(input) {
|
||||||
|
_interpreter = new atn::LexerATNSimulator(this, _atn, _decisionToDFA, _sharedContextCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
bfeLexer::~bfeLexer() {
|
||||||
|
delete _interpreter;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string bfeLexer::getGrammarFileName() const {
|
||||||
|
return "bfe.g4";
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<std::string>& bfeLexer::getRuleNames() const {
|
||||||
|
return _ruleNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<std::string>& bfeLexer::getChannelNames() const {
|
||||||
|
return _channelNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<std::string>& bfeLexer::getModeNames() const {
|
||||||
|
return _modeNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<std::string>& bfeLexer::getTokenNames() const {
|
||||||
|
return _tokenNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
dfa::Vocabulary& bfeLexer::getVocabulary() const {
|
||||||
|
return _vocabulary;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<uint16_t> bfeLexer::getSerializedATN() const {
|
||||||
|
return _serializedATN;
|
||||||
|
}
|
||||||
|
|
||||||
|
const atn::ATN& bfeLexer::getATN() const {
|
||||||
|
return _atn;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Static vars and initialization.
|
||||||
|
std::vector<dfa::DFA> bfeLexer::_decisionToDFA;
|
||||||
|
atn::PredictionContextCache bfeLexer::_sharedContextCache;
|
||||||
|
|
||||||
|
// We own the ATN which in turn owns the ATN states.
|
||||||
|
atn::ATN bfeLexer::_atn;
|
||||||
|
std::vector<uint16_t> bfeLexer::_serializedATN;
|
||||||
|
|
||||||
|
std::vector<std::string> bfeLexer::_ruleNames = {
|
||||||
|
u8"NEWLINE", u8"COMMENT", u8"ML_COMMENT", u8"DEF", u8"LOOPSTART", u8"LOOPEND",
|
||||||
|
u8"GRPSTART", u8"GRPEND", u8"NUMBER", u8"INPUT", u8"OUTPUT", u8"DEC",
|
||||||
|
u8"INC", u8"LEFT", u8"RIGHT", u8"EVERYTHING_ELSE", u8"WS"
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<std::string> bfeLexer::_channelNames = {
|
||||||
|
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<std::string> bfeLexer::_modeNames = {
|
||||||
|
u8"DEFAULT_MODE"
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<std::string> bfeLexer::_literalNames = {
|
||||||
|
"", u8"'\n'", "", "", u8"'#'", u8"'['", u8"']'", u8"'('", u8"')'", "",
|
||||||
|
u8"','", u8"'.'", u8"'-'", u8"'+'", u8"'<'", u8"'>'"
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<std::string> bfeLexer::_symbolicNames = {
|
||||||
|
"", u8"NEWLINE", u8"COMMENT", u8"ML_COMMENT", u8"DEF", u8"LOOPSTART",
|
||||||
|
u8"LOOPEND", u8"GRPSTART", u8"GRPEND", u8"NUMBER", u8"INPUT", u8"OUTPUT",
|
||||||
|
u8"DEC", u8"INC", u8"LEFT", u8"RIGHT", u8"EVERYTHING_ELSE", u8"WS"
|
||||||
|
};
|
||||||
|
|
||||||
|
dfa::Vocabulary bfeLexer::_vocabulary(_literalNames, _symbolicNames);
|
||||||
|
|
||||||
|
std::vector<std::string> bfeLexer::_tokenNames;
|
||||||
|
|
||||||
|
bfeLexer::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, 0x13, 0x6b, 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, 0x4, 0xe, 0x9,
|
||||||
|
0xe, 0x4, 0xf, 0x9, 0xf, 0x4, 0x10, 0x9, 0x10, 0x4, 0x11, 0x9, 0x11,
|
||||||
|
0x4, 0x12, 0x9, 0x12, 0x3, 0x2, 0x3, 0x2, 0x3, 0x2, 0x3, 0x2, 0x3, 0x3,
|
||||||
|
0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x7, 0x3, 0x2e, 0xa, 0x3, 0xc, 0x3, 0xe,
|
||||||
|
0x3, 0x31, 0xb, 0x3, 0x3, 0x3, 0x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x3, 0x2, 0x2, 0x2, 0x59,
|
||||||
|
0x5a, 0x7, 0x30, 0x2, 0x2, 0x5a, 0x18, 0x3, 0x2, 0x2, 0x2, 0x5b, 0x5c,
|
||||||
|
0x7, 0x2f, 0x2, 0x2, 0x5c, 0x1a, 0x3, 0x2, 0x2, 0x2, 0x5d, 0x5e, 0x7,
|
||||||
|
0x2d, 0x2, 0x2, 0x5e, 0x1c, 0x3, 0x2, 0x2, 0x2, 0x5f, 0x60, 0x7, 0x3e,
|
||||||
|
0x2, 0x2, 0x60, 0x1e, 0x3, 0x2, 0x2, 0x2, 0x61, 0x62, 0x7, 0x40, 0x2,
|
||||||
|
0x2, 0x62, 0x20, 0x3, 0x2, 0x2, 0x2, 0x63, 0x64, 0xb, 0x2, 0x2, 0x2,
|
||||||
|
0x64, 0x65, 0x3, 0x2, 0x2, 0x2, 0x65, 0x66, 0x8, 0x11, 0x3, 0x2, 0x66,
|
||||||
|
0x22, 0x3, 0x2, 0x2, 0x2, 0x67, 0x68, 0x9, 0x4, 0x2, 0x2, 0x68, 0x69,
|
||||||
|
0x3, 0x2, 0x2, 0x2, 0x69, 0x6a, 0x8, 0x12, 0x2, 0x2, 0x6a, 0x24, 0x3,
|
||||||
|
0x2, 0x2, 0x2, 0x8, 0x2, 0x2f, 0x33, 0x36, 0x40, 0x55, 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bfeLexer::Initializer bfeLexer::_init;
|
58
lib/generated/bfeLexer.h
generated
Normal file
58
lib/generated/bfeLexer.h
generated
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
|
||||||
|
// Generated from /home/atreya/Documents/Projects/Miscellaneous/bfc/grammar/bfe.g4 by ANTLR 4.8
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
#include "antlr4-runtime.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class bfeLexer : public antlr4::Lexer {
|
||||||
|
public:
|
||||||
|
enum {
|
||||||
|
NEWLINE = 1, COMMENT = 2, ML_COMMENT = 3, DEF = 4, LOOPSTART = 5, LOOPEND = 6,
|
||||||
|
GRPSTART = 7, GRPEND = 8, NUMBER = 9, INPUT = 10, OUTPUT = 11, DEC = 12,
|
||||||
|
INC = 13, LEFT = 14, RIGHT = 15, EVERYTHING_ELSE = 16, WS = 17
|
||||||
|
};
|
||||||
|
|
||||||
|
bfeLexer(antlr4::CharStream *input);
|
||||||
|
~bfeLexer();
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
29
lib/generated/bfeLexer.tokens
generated
Normal file
29
lib/generated/bfeLexer.tokens
generated
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
NEWLINE=1
|
||||||
|
COMMENT=2
|
||||||
|
ML_COMMENT=3
|
||||||
|
DEF=4
|
||||||
|
LOOPSTART=5
|
||||||
|
LOOPEND=6
|
||||||
|
GRPSTART=7
|
||||||
|
GRPEND=8
|
||||||
|
NUMBER=9
|
||||||
|
INPUT=10
|
||||||
|
OUTPUT=11
|
||||||
|
DEC=12
|
||||||
|
INC=13
|
||||||
|
LEFT=14
|
||||||
|
RIGHT=15
|
||||||
|
EVERYTHING_ELSE=16
|
||||||
|
WS=17
|
||||||
|
'\n'=1
|
||||||
|
'#'=4
|
||||||
|
'['=5
|
||||||
|
']'=6
|
||||||
|
'('=7
|
||||||
|
')'=8
|
||||||
|
','=10
|
||||||
|
'.'=11
|
||||||
|
'-'=12
|
||||||
|
'+'=13
|
||||||
|
'<'=14
|
||||||
|
'>'=15
|
7
lib/generated/bfeListener.cpp
generated
Normal file
7
lib/generated/bfeListener.cpp
generated
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
// Generated from /home/atreya/Documents/Projects/Miscellaneous/bfc/grammar/bfe.g4 by ANTLR 4.8
|
||||||
|
|
||||||
|
|
||||||
|
#include "bfeListener.h"
|
||||||
|
|
||||||
|
|
61
lib/generated/bfeListener.h
generated
Normal file
61
lib/generated/bfeListener.h
generated
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
|
||||||
|
// Generated from /home/atreya/Documents/Projects/Miscellaneous/bfc/grammar/bfe.g4 by ANTLR 4.8
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
#include "antlr4-runtime.h"
|
||||||
|
#include "bfeParser.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface defines an abstract listener for a parse tree produced by bfeParser.
|
||||||
|
*/
|
||||||
|
class bfeListener : public antlr4::tree::ParseTreeListener {
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void enterProgram(bfeParser::ProgramContext *ctx) = 0;
|
||||||
|
virtual void exitProgram(bfeParser::ProgramContext *ctx) = 0;
|
||||||
|
|
||||||
|
virtual void enterStatements(bfeParser::StatementsContext *ctx) = 0;
|
||||||
|
virtual void exitStatements(bfeParser::StatementsContext *ctx) = 0;
|
||||||
|
|
||||||
|
virtual void enterEligibleStmt(bfeParser::EligibleStmtContext *ctx) = 0;
|
||||||
|
virtual void exitEligibleStmt(bfeParser::EligibleStmtContext *ctx) = 0;
|
||||||
|
|
||||||
|
virtual void enterNumberedStmt(bfeParser::NumberedStmtContext *ctx) = 0;
|
||||||
|
virtual void exitNumberedStmt(bfeParser::NumberedStmtContext *ctx) = 0;
|
||||||
|
|
||||||
|
virtual void enterStmt(bfeParser::StmtContext *ctx) = 0;
|
||||||
|
virtual void exitStmt(bfeParser::StmtContext *ctx) = 0;
|
||||||
|
|
||||||
|
virtual void enterGroupedStmt(bfeParser::GroupedStmtContext *ctx) = 0;
|
||||||
|
virtual void exitGroupedStmt(bfeParser::GroupedStmtContext *ctx) = 0;
|
||||||
|
|
||||||
|
virtual void enterLoopStmt(bfeParser::LoopStmtContext *ctx) = 0;
|
||||||
|
virtual void exitLoopStmt(bfeParser::LoopStmtContext *ctx) = 0;
|
||||||
|
|
||||||
|
virtual void enterBasicStmt(bfeParser::BasicStmtContext *ctx) = 0;
|
||||||
|
virtual void exitBasicStmt(bfeParser::BasicStmtContext *ctx) = 0;
|
||||||
|
|
||||||
|
virtual void enterPtrIncr(bfeParser::PtrIncrContext *ctx) = 0;
|
||||||
|
virtual void exitPtrIncr(bfeParser::PtrIncrContext *ctx) = 0;
|
||||||
|
|
||||||
|
virtual void enterPtrDecr(bfeParser::PtrDecrContext *ctx) = 0;
|
||||||
|
virtual void exitPtrDecr(bfeParser::PtrDecrContext *ctx) = 0;
|
||||||
|
|
||||||
|
virtual void enterPtrLeft(bfeParser::PtrLeftContext *ctx) = 0;
|
||||||
|
virtual void exitPtrLeft(bfeParser::PtrLeftContext *ctx) = 0;
|
||||||
|
|
||||||
|
virtual void enterPtrRight(bfeParser::PtrRightContext *ctx) = 0;
|
||||||
|
virtual void exitPtrRight(bfeParser::PtrRightContext *ctx) = 0;
|
||||||
|
|
||||||
|
virtual void enterInputStmt(bfeParser::InputStmtContext *ctx) = 0;
|
||||||
|
virtual void exitInputStmt(bfeParser::InputStmtContext *ctx) = 0;
|
||||||
|
|
||||||
|
virtual void enterOutputStmt(bfeParser::OutputStmtContext *ctx) = 0;
|
||||||
|
virtual void exitOutputStmt(bfeParser::OutputStmtContext *ctx) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
1131
lib/generated/bfeParser.cpp
generated
Normal file
1131
lib/generated/bfeParser.cpp
generated
Normal file
File diff suppressed because it is too large
Load Diff
296
lib/generated/bfeParser.h
generated
Normal file
296
lib/generated/bfeParser.h
generated
Normal file
@@ -0,0 +1,296 @@
|
|||||||
|
|
||||||
|
// Generated from /home/atreya/Documents/Projects/Miscellaneous/bfc/grammar/bfe.g4 by ANTLR 4.8
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
#include "antlr4-runtime.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class bfeParser : public antlr4::Parser {
|
||||||
|
public:
|
||||||
|
enum {
|
||||||
|
NEWLINE = 1, COMMENT = 2, ML_COMMENT = 3, DEF = 4, LOOPSTART = 5, LOOPEND = 6,
|
||||||
|
GRPSTART = 7, GRPEND = 8, NUMBER = 9, INPUT = 10, OUTPUT = 11, DEC = 12,
|
||||||
|
INC = 13, LEFT = 14, RIGHT = 15, EVERYTHING_ELSE = 16, WS = 17
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
RuleProgram = 0, RuleStatements = 1, RuleEligibleStmt = 2, RuleNumberedStmt = 3,
|
||||||
|
RuleStmt = 4, RuleGroupedStmt = 5, RuleLoopStmt = 6, RuleBasicStmt = 7,
|
||||||
|
RulePtrIncr = 8, RulePtrDecr = 9, RulePtrLeft = 10, RulePtrRight = 11,
|
||||||
|
RuleInputStmt = 12, RuleOutputStmt = 13
|
||||||
|
};
|
||||||
|
|
||||||
|
bfeParser(antlr4::TokenStream *input);
|
||||||
|
~bfeParser();
|
||||||
|
|
||||||
|
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 EligibleStmtContext;
|
||||||
|
class NumberedStmtContext;
|
||||||
|
class StmtContext;
|
||||||
|
class GroupedStmtContext;
|
||||||
|
class LoopStmtContext;
|
||||||
|
class BasicStmtContext;
|
||||||
|
class PtrIncrContext;
|
||||||
|
class PtrDecrContext;
|
||||||
|
class PtrLeftContext;
|
||||||
|
class PtrRightContext;
|
||||||
|
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();
|
||||||
|
StatementsContext *statements();
|
||||||
|
|
||||||
|
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<EligibleStmtContext *> eligibleStmt();
|
||||||
|
EligibleStmtContext* eligibleStmt(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 EligibleStmtContext : public antlr4::ParserRuleContext {
|
||||||
|
public:
|
||||||
|
EligibleStmtContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||||
|
virtual size_t getRuleIndex() const override;
|
||||||
|
StmtContext *stmt();
|
||||||
|
NumberedStmtContext *numberedStmt();
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
EligibleStmtContext* eligibleStmt();
|
||||||
|
|
||||||
|
class NumberedStmtContext : public antlr4::ParserRuleContext {
|
||||||
|
public:
|
||||||
|
NumberedStmtContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||||
|
virtual size_t getRuleIndex() const override;
|
||||||
|
StmtContext *stmt();
|
||||||
|
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;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
NumberedStmtContext* numberedStmt();
|
||||||
|
|
||||||
|
class StmtContext : public antlr4::ParserRuleContext {
|
||||||
|
public:
|
||||||
|
StmtContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||||
|
virtual size_t getRuleIndex() const override;
|
||||||
|
BasicStmtContext *basicStmt();
|
||||||
|
GroupedStmtContext *groupedStmt();
|
||||||
|
LoopStmtContext *loopStmt();
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
StmtContext* stmt();
|
||||||
|
|
||||||
|
class GroupedStmtContext : public antlr4::ParserRuleContext {
|
||||||
|
public:
|
||||||
|
GroupedStmtContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||||
|
virtual size_t getRuleIndex() const override;
|
||||||
|
antlr4::tree::TerminalNode *GRPSTART();
|
||||||
|
StatementsContext *statements();
|
||||||
|
antlr4::tree::TerminalNode *GRPEND();
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
GroupedStmtContext* groupedStmt();
|
||||||
|
|
||||||
|
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 BasicStmtContext : public antlr4::ParserRuleContext {
|
||||||
|
public:
|
||||||
|
BasicStmtContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||||
|
virtual size_t getRuleIndex() const override;
|
||||||
|
PtrIncrContext *ptrIncr();
|
||||||
|
PtrDecrContext *ptrDecr();
|
||||||
|
PtrLeftContext *ptrLeft();
|
||||||
|
PtrRightContext *ptrRight();
|
||||||
|
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;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
BasicStmtContext* basicStmt();
|
||||||
|
|
||||||
|
class PtrIncrContext : public antlr4::ParserRuleContext {
|
||||||
|
public:
|
||||||
|
PtrIncrContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||||
|
virtual size_t getRuleIndex() const override;
|
||||||
|
antlr4::tree::TerminalNode *INC();
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
PtrIncrContext* ptrIncr();
|
||||||
|
|
||||||
|
class PtrDecrContext : public antlr4::ParserRuleContext {
|
||||||
|
public:
|
||||||
|
PtrDecrContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||||
|
virtual size_t getRuleIndex() const override;
|
||||||
|
antlr4::tree::TerminalNode *DEC();
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
PtrDecrContext* ptrDecr();
|
||||||
|
|
||||||
|
class PtrLeftContext : public antlr4::ParserRuleContext {
|
||||||
|
public:
|
||||||
|
PtrLeftContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||||
|
virtual size_t getRuleIndex() const override;
|
||||||
|
antlr4::tree::TerminalNode *LEFT();
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
PtrLeftContext* ptrLeft();
|
||||||
|
|
||||||
|
class PtrRightContext : public antlr4::ParserRuleContext {
|
||||||
|
public:
|
||||||
|
PtrRightContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||||
|
virtual size_t getRuleIndex() const override;
|
||||||
|
antlr4::tree::TerminalNode *RIGHT();
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
PtrRightContext* ptrRight();
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
7
lib/generated/bfeVisitor.cpp
generated
Normal file
7
lib/generated/bfeVisitor.cpp
generated
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
// Generated from /home/atreya/Documents/Projects/Miscellaneous/bfc/grammar/bfe.g4 by ANTLR 4.8
|
||||||
|
|
||||||
|
|
||||||
|
#include "bfeVisitor.h"
|
||||||
|
|
||||||
|
|
52
lib/generated/bfeVisitor.h
generated
Normal file
52
lib/generated/bfeVisitor.h
generated
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
|
||||||
|
// Generated from /home/atreya/Documents/Projects/Miscellaneous/bfc/grammar/bfe.g4 by ANTLR 4.8
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
#include "antlr4-runtime.h"
|
||||||
|
#include "bfeParser.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class defines an abstract visitor for a parse tree
|
||||||
|
* produced by bfeParser.
|
||||||
|
*/
|
||||||
|
class bfeVisitor : public antlr4::tree::AbstractParseTreeVisitor {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Visit parse trees produced by bfeParser.
|
||||||
|
*/
|
||||||
|
virtual antlrcpp::Any visitProgram(bfeParser::ProgramContext *context) = 0;
|
||||||
|
|
||||||
|
virtual antlrcpp::Any visitStatements(bfeParser::StatementsContext *context) = 0;
|
||||||
|
|
||||||
|
virtual antlrcpp::Any visitEligibleStmt(bfeParser::EligibleStmtContext *context) = 0;
|
||||||
|
|
||||||
|
virtual antlrcpp::Any visitNumberedStmt(bfeParser::NumberedStmtContext *context) = 0;
|
||||||
|
|
||||||
|
virtual antlrcpp::Any visitStmt(bfeParser::StmtContext *context) = 0;
|
||||||
|
|
||||||
|
virtual antlrcpp::Any visitGroupedStmt(bfeParser::GroupedStmtContext *context) = 0;
|
||||||
|
|
||||||
|
virtual antlrcpp::Any visitLoopStmt(bfeParser::LoopStmtContext *context) = 0;
|
||||||
|
|
||||||
|
virtual antlrcpp::Any visitBasicStmt(bfeParser::BasicStmtContext *context) = 0;
|
||||||
|
|
||||||
|
virtual antlrcpp::Any visitPtrIncr(bfeParser::PtrIncrContext *context) = 0;
|
||||||
|
|
||||||
|
virtual antlrcpp::Any visitPtrDecr(bfeParser::PtrDecrContext *context) = 0;
|
||||||
|
|
||||||
|
virtual antlrcpp::Any visitPtrLeft(bfeParser::PtrLeftContext *context) = 0;
|
||||||
|
|
||||||
|
virtual antlrcpp::Any visitPtrRight(bfeParser::PtrRightContext *context) = 0;
|
||||||
|
|
||||||
|
virtual antlrcpp::Any visitInputStmt(bfeParser::InputStmtContext *context) = 0;
|
||||||
|
|
||||||
|
virtual antlrcpp::Any visitOutputStmt(bfeParser::OutputStmtContext *context) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
0
thirdparty/antlr/.place-antlr-here
vendored
0
thirdparty/antlr/.place-antlr-here
vendored
Reference in New Issue
Block a user