Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
Co-authored-by: Joshua Carlson <jrcarl624@users.noreply.github.com>
  • Loading branch information
Ze7111 and jrcarl624 committed Jul 6, 2024
1 parent 9e01853 commit dcb6712
Show file tree
Hide file tree
Showing 10 changed files with 277 additions and 25 deletions.
6 changes: 3 additions & 3 deletions source/core/utils/josnify.hh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
* @note This code is provided by the creators of Helix. Visit our website at:
* https://helix-lang.com/ for more information.
*/
#ifndef __JOSNIFY_H__
#define __JOSNIFY_H__
#ifndef __JOSNIFY_HH__
#define __JOSNIFY_HH__

#include <string>
#include <type_traits>
Expand Down Expand Up @@ -72,4 +72,4 @@ constexpr inline std::string to_json(T key, const u32 &depth, const std::string
}
} // end namespace jsonify

#endif // __JOSNIFY_H__
#endif // __JOSNIFY_HH__
6 changes: 3 additions & 3 deletions source/generator/include/cxx_emitter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
* @note This code is provided by the creators of Helix. Visit our website at:
* https://helix-lang.com/ for more information.
*/
#ifndef __CXX_EMITTER_H__
#define __CXX_EMITTER_H__
#ifndef __CXX_EMITTER_HH__
#define __CXX_EMITTER_HH__

#include <cstddef>
#include <cstdlib>
Expand Down Expand Up @@ -208,4 +208,4 @@ struct CXXBuilder {
};
}

#endif // __CXX_EMITTER_H__
#endif // __CXX_EMITTER_HH__
6 changes: 3 additions & 3 deletions source/generator/include/llvm_emitter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
* @note This code is provided by the creators of Helix. Visit our website at:
* https://helix-lang.com/ for more information.
*/
#ifndef __LLVM_EMITTER_H__
#define __LLVM_EMITTER_H__
#ifndef __LLVM_EMITTER_HH__
#define __LLVM_EMITTER_HH__

namespace codegen::llvm {

}

#endif // __LLVM_EMITTER_H__
#endif // __LLVM_EMITTER_HH__
6 changes: 3 additions & 3 deletions source/generator/include/py_emitter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
* @note This code is provided by the creators of Helix. Visit our website at:
* https://helix-lang.com/ for more information.
*/
#ifndef __PYTHON_EMITTER_H__
#define __PYTHON_EMITTER_H__
#ifndef __PYTHON_EMITTER_HH__
#define __PYTHON_EMITTER_HH__

namespace codegen::python {

}

#endif // __PYTHON_EMITTER_H__
#endif // __PYTHON_EMITTER_HH__
6 changes: 3 additions & 3 deletions source/generator/include/rs_emitter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
* @note This code is provided by the creators of Helix. Visit our website at:
* https://helix-lang.com/ for more information.
*/
#ifndef __RUST_EMITTER_H__
#define __RUST_EMITTER_H__
#ifndef __RUST_EMITTER_HH__
#define __RUST_EMITTER_HH__

namespace codegen::rust {

}

#endif // __RUST_EMITTER_H__
#endif // __RUST_EMITTER_HH__
4 changes: 3 additions & 1 deletion source/lexer/include/lexer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
namespace lexer {
class Lexer {
public:
// TODO: Investigate if we can make this string not a copy
Lexer(std::string source, const std::string &filename);
explicit Lexer(const token::Token& token);
Lexer(const Lexer &lexer) = delete;
Lexer(Lexer &&lexer) = delete;
Lexer &operator=(const Lexer &lexer) = delete;
Lexer &operator=(Lexer &&lexer) = delete;
~Lexer() = default;

token::TokenList tokenize();

private:
Expand Down
12 changes: 12 additions & 0 deletions source/lexer/source/lexer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ Lexer::Lexer(std::string source, const std::string &filename)
, offset(0)
, end(this->source.size()) {}

Lexer::Lexer(const token::Token& token)
: tokens(token.file_name())
, source(token.value())
, file_name(token.file_name())
, currentChar('\0')
, cachePos(0)
, currentPos(0)
, line(token.line_number())
, column(token.column_number())
, offset(token.offset())
, end(this->source.size()) {}

TokenList Lexer::tokenize() {
token::Token token;

Expand Down
16 changes: 10 additions & 6 deletions source/parser/ast/include/ast.hh
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ namespace parser::ast {
struct ParseError {};

using TokenListRef = std::shared_ptr<token::TokenList>;
using ParseResult = std::expected<u64, ParseError>; // len of tokens to skip | recoverable error
using ParseResult = std::expected<u64, ParseError>; // len of tokens to skip | recoverable error

template <typename T>
struct ASTBase;

template <>
struct ASTBase<void> {
// virtual std::expected<std::span<Token>,AstError> parse(std::span<Token> tokens) = 0;
ASTBase() = default;
ASTBase(ASTBase &&) = default;
ASTBase(const ASTBase &) = default;
Expand All @@ -59,17 +58,22 @@ struct ASTBase : public ASTBase<void> {
~ASTBase() = default;
};

struct Declarations : public ASTBase<Declarations> {};
struct Expressions : public ASTBase<Expressions> {};
struct Annotations : public ASTBase<Annotations> {};
struct Statements : public ASTBase<Statements> {};
struct Types : public ASTBase<Types> {};

template <typename T = void>
concept ASTNode = std::derived_from<T, ASTBase<T>>;

template <typename T = void>
using NodePtr = std::shared_ptr<ASTBase<T>>;
using NodePtr = std::shared_ptr<ASTBase<T>>;

template <typename T = void>
using NodeList = std::vector<NodePtr<T>>;
using NodeList = std::vector<NodePtr<T>>;

template <typename T = void>
using Slice = const std::reference_wrapper<NodeList<T>>;

using Slice = const std::reference_wrapper<NodeList<T>>;
} // namespace parser::ast
#endif // __AST_HH__
6 changes: 3 additions & 3 deletions source/parser/ast/include/nodes.hh
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
* @note This code is provided by the creators of Helix. Visit our website at:
* https://helix-lang.com/ for more information.
*/
#ifndef __NODES_H__
#define __NODES_H__
#ifndef __AST_NODES_HH__
#define __AST_NODES_HH__

#include "parser/ast/include/ast.hh"

namespace parser::ast::node {
struct Program : ASTBase<Program> {};
}

#endif // __NODES_H__
#endif // __AST_NODES_HH__
Loading

0 comments on commit dcb6712

Please sign in to comment.