Compare commits
4 Commits
main
...
tmp-parser
| Author | SHA1 | Date | |
|---|---|---|---|
| 5ba801a756 | |||
| 86d069d3d9 | |||
| ea067b6c54 | |||
| 701f0e595d |
@ -1,5 +1,45 @@
|
||||
#include <print>
|
||||
#include <fstream>
|
||||
|
||||
int main(int, char **) {
|
||||
std::println("[LOG] Hello world");
|
||||
#include <artichoke/Parser/Parser.hpp>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
using namespace arti::lang;
|
||||
|
||||
if (argc < 2) {
|
||||
std::println("Usage:\n {} <filename>", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::ifstream file;
|
||||
file.open(argv[1]);
|
||||
|
||||
if (!file.is_open()) {
|
||||
std::println("Failed to open file {}", argv[1]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::string buffer{
|
||||
std::istreambuf_iterator<char>(file),
|
||||
std::istreambuf_iterator<char>()
|
||||
};
|
||||
|
||||
Tokenizer tokenizer{buffer};
|
||||
|
||||
auto result = MatcherRule<rules::Program>::parse(&tokenizer, 0);
|
||||
|
||||
if (!result) {
|
||||
auto err = std::move(result).error();
|
||||
std::println(
|
||||
"Error at line {}, column {}. {}",
|
||||
err.line,
|
||||
err.column,
|
||||
err.message
|
||||
);
|
||||
}
|
||||
else {
|
||||
std::println("Valid source");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1 @@
|
||||
#include <artichoke/Parser/Parser.hpp>
|
||||
Loading…
x
Reference in New Issue
Block a user