@@ -1,10 +1,13 @@
|
||||
#include "furc/front/lexer.hpp"
|
||||
|
||||
#include <cctype>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace furc::front {
|
||||
|
||||
using namespace std::string_literals;
|
||||
|
||||
lexer::lexer(std::string_view filename, std::string_view content)
|
||||
: m_filename(filename), m_content(content) {}
|
||||
|
||||
@@ -45,7 +48,7 @@ token_handle<> lexer::next_token() {
|
||||
return { location, token_t::Identifier, value };
|
||||
}
|
||||
|
||||
return { location, error_token::UnexpectedCharacter, m_content.substr(m_cursor, 1) };
|
||||
return { location, "unexpected character '"s.append(m_content.substr(m_cursor, 1)) + "'" };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,6 @@ ast::node_handle<ast::declaration_node> parser::parse_declaration() {
|
||||
return ast::node_handle<ast::function_declarartion_node>{ first.location(), name };
|
||||
}
|
||||
case token_t::None:
|
||||
case token_t::Error:
|
||||
case token_t::Identifier:
|
||||
case token_t::Keyword:
|
||||
case token_t::Integer:
|
||||
@@ -84,7 +83,6 @@ ast::node_handle<ast::declaration_node> parser::parse_declaration() {
|
||||
}
|
||||
}
|
||||
case token_t::None:
|
||||
case token_t::Error:
|
||||
case token_t::Identifier:
|
||||
case token_t::Integer:
|
||||
case token_t::Lparen:
|
||||
|
||||
+5
-1
@@ -1,3 +1,5 @@
|
||||
#ifndef LIBFURC
|
||||
|
||||
#include "furc/front/parser.hpp"
|
||||
|
||||
#include <iostream>
|
||||
@@ -7,4 +9,6 @@ int main(void) {
|
||||
std::cout << parser.parse() << '\n';
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // LIBFURC
|
||||
Reference in New Issue
Block a user