Skip to content
This repository has been archived by the owner on Jun 29, 2024. It is now read-only.

Commit

Permalink
Add class Parser to use FilParser
Browse files Browse the repository at this point in the history
  • Loading branch information
Gashmob committed Jul 16, 2023
1 parent 3a8777c commit cd4bbee
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ add_library(compiler_lib
utils/OptionsParser.cpp
# === ANTLR ===
${ANTLR_Lexer_CXX_OUTPUTS} ${ANTLR_Parser_CXX_OUTPUTS}
grammar/Lexer.cpp
grammar/Lexer.cpp grammar/Parser.cpp
# === Message ===
message/Message.cpp message/MessageCollector.cpp message/Warning.cpp message/Error.cpp)
target_include_directories(compiler_lib PUBLIC
Expand Down
3 changes: 3 additions & 0 deletions src/lib/FilCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "MessageCollector.h"
#include "Error.h"
#include "Lexer.h"
#include "Parser.h"
#include <utility>
#include <future>

Expand All @@ -43,6 +44,8 @@ namespace filc {
try {
filc::grammar::Lexer lexer(filename);

filc::grammar::Parser parser(lexer.getTokens());

return true;
} catch (std::exception &e) {
collector->addError(new filc::message::BasicError(5, e.what()));
Expand Down
31 changes: 31 additions & 0 deletions src/lib/grammar/Parser.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* MIT License
*
* Copyright (c) 2023-Present Kevin Traini
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "Parser.h"
#include "FilParser.h"

namespace filc::grammar {
Parser::Parser(antlr4::CommonTokenStream *tokens) {
FilParser parser(tokens);
}
}
36 changes: 36 additions & 0 deletions src/lib/grammar/Parser.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* MIT License
*
* Copyright (c) 2023-Present Kevin Traini
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef FILC_PARSER_H
#define FILC_PARSER_H

#include "antlr4-runtime.h"

namespace filc::grammar {
class Parser {
public:
explicit Parser(antlr4::CommonTokenStream *tokens);
};
}

#endif //FILC_PARSER_H

0 comments on commit cd4bbee

Please sign in to comment.