Skip to content

Commit

Permalink
feat(parser): extend support for additional type specifier, improves …
Browse files Browse the repository at this point in the history
…flexibility and extensibility
  • Loading branch information
Ze7111 committed Oct 25, 2024
1 parent c027d39 commit cb881eb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- [ ] Fix ast error messages, where the message tells a fix to also add a quick fix to the error
- [x] Add support for global scopes in the parser
- [ ] Add panic unwinding support
- [ ] Parse and add extend support for generic specializations

# Completed:
### Parser:
Expand Down
2 changes: 1 addition & 1 deletion source/helix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include "controller/include/Controller.hh"
#include "generator/include/CX-IR/CXIR.hh"
#include "lexer/include/lexer.hh"
#include "parser/preprocessor/include/preprocessor.hh"
#include "parser/preprocessor/include/PreProcessor.hh"

enum class LogLevel { Debug, Info, Warning, Error };
inline bool NO_LOGS = false;
Expand Down
12 changes: 9 additions & 3 deletions source/parser/ast/include/types/AST_modifiers.hh
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,14 @@ __AST_BEGIN {
Module, ///< 'module'
Ffi, ///< 'ffi'
Unsafe, ///< 'unsafe'
Static, ///< 'static'
};

static bool is_type_qualifier(const __TOKEN_N::Token &tok) {
return tok == __TOKEN_N::KEYWORD_CONST || tok == __TOKEN_N::KEYWORD_MODULE ||
tok == __TOKEN_N::KEYWORD_YIELD || tok == __TOKEN_N::KEYWORD_ASYNC ||
tok == __TOKEN_N::KEYWORD_FFI || tok == __TOKEN_N::KEYWORD_UNSAFE;
tok == __TOKEN_N::KEYWORD_FFI || tok == __TOKEN_N::KEYWORD_UNSAFE ||
tok == __TOKEN_N::KEYWORD_STATIC;
}

explicit TypeSpecifier(__TOKEN_N::Token marker)
Expand All @@ -162,6 +164,9 @@ __AST_BEGIN {
case __TOKEN_N::KEYWORD_UNSAFE:
type = Specifier::Unsafe;
break;
case __TOKEN_N::KEYWORD_STATIC:
type = Specifier::Static;
break;
default:
throw std::runtime_error("Invalid type specifier");
break;
Expand Down Expand Up @@ -391,7 +396,8 @@ __AST_BEGIN {
__TOKEN_N::KEYWORD_YIELD,
__TOKEN_N::KEYWORD_ASYNC,
__TOKEN_N::KEYWORD_FFI,
__TOKEN_N::KEYWORD_UNSAFE}},
__TOKEN_N::KEYWORD_UNSAFE,
__TOKEN_N::KEYWORD_STATIC}},
{ExpectedModifier::AccessSpec,
{__TOKEN_N::KEYWORD_PUBLIC,
__TOKEN_N::KEYWORD_PRIVATE,
Expand Down Expand Up @@ -502,7 +508,7 @@ __AST_BEGIN {
}

template <typename T>
[[nodiscard]] std::vector<T> get() {
[[nodiscard]] std::vector<T> get() const {
std::vector<T> result;

for (const auto &modifier : modifiers) {
Expand Down

0 comments on commit cb881eb

Please sign in to comment.