generated from bialger/cpp_tests
-
Notifications
You must be signed in to change notification settings - Fork 0
Parser!! #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
biqiboqi
wants to merge
29
commits into
master
Choose a base branch
from
parser
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Parser!! #20
Changes from 4 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
bbfbbc8
feat: add parser interfaces and classes
biqiboqi 50ae1f1
fix: clang issues fixed
biqiboqi 4ac3bd2
refactor: SPACES
biqiboqi dd4dd26
refactor: IState forward declaration fix
biqiboqi 771ef20
feat: afterreview fixes
biqiboqi 6003896
fix: fix branch class
biqiboqi cd624eb
fix: fix branch class and some lil mistakes
biqiboqi 1b4c52a
fix: I HATE !$@$!%#@$!@ CI/CD WITH !*@#^&!(@&#^ CODESTYLE
biqiboqi 1094bf4
fix: fixed SafeCall
biqiboqi 0d66cef
feat: add ast nodes implementation
biqiboqi e191c32
feat: add ast visitors and OpTags
biqiboqi aec527f
feat: add contexts
biqiboqi cadbe0e
feat: add types
biqiboqi 2a390fe
feat: add diagnostics
biqiboqi 1850ca9
feat: add LintVisitor
biqiboqi 0a2a9d7
feat: add vector token stream
biqiboqi f675de4
feat: add vector token stream
biqiboqi 0a0a249
fix: deleted accidentally added file
biqiboqi ceef53b
Merge branch 'master' into parser
bialger 82816b8
fix: update include directive for MethodDecl.cpp
bialger 4e4f497
refactor: add namespace closure to parser files and update header guards
bialger 5ec413a
refactor: optimize Diagnostic methods by using move semantics and add…
bialger 555ea73
feat: add builders for ast nodes, add SourceSpan in ast nodes
biqiboqi 15dbbfc
feat: implement token matchers
biqiboqi 8aab101
feat: add const to states, implemented ParserFSM
biqiboqi 938f642
feat: add pratt parser initial and ast factory
biqiboqi ae421a1
feat: enhance pratt parser with additional grammar rules and error ha…
biqiboqi 185957e
feat: improve pratt parser with enhanced error reporting and addition…
biqiboqi 0021fbf
feat: add bytecode visitor and tests
biqiboqi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #ifndef IPARSER_HPP_ | ||
| #define IPARSER_HPP_ | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include "ast/nodes/decls/Module.hpp" | ||
| #include "diagnostics/IDiagnosticSink.hpp" | ||
| #include "tokens/token_streams/ITokenStream.hpp" | ||
|
|
||
| class IParser { | ||
| public: | ||
| virtual ~IParser() = default; | ||
| virtual std::unique_ptr<Module> Parse(ITokenStream& ts, IDiagnosticSink& diags) = 0; | ||
| }; | ||
|
|
||
| #endif // IPARSER_HPP_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #include "ParserFsm.hpp" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| #ifndef PARSERFSM_HPP_ | ||
| #define PARSERFSM_HPP_ | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include "IParser.hpp" | ||
| #include "ast/IAstFactory.hpp" | ||
| #include "pratt/IExpressionParser.hpp" | ||
| #include "type_parser/ITypeParser.hpp" | ||
|
|
||
| class ParserFsm : public IParser { | ||
| public: | ||
| ParserFsm(std::unique_ptr<IExpressionParser> expr, | ||
| std::unique_ptr<ITypeParser> typep, | ||
| std::unique_ptr<IAstFactory> factory); | ||
|
|
||
| ~ParserFsm() override = default; | ||
|
|
||
| std::unique_ptr<Module> Parse(ITokenStream& ts, IDiagnosticSink& diags) override; | ||
|
|
||
| private: | ||
| std::unique_ptr<IExpressionParser> expr_parser_; | ||
| std::unique_ptr<ITypeParser> type_parser_; | ||
| std::unique_ptr<IAstFactory> factory_; | ||
| }; | ||
|
|
||
| #endif // PARSERFSM_HPP_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| #ifndef ASTVISITOR_HPP_ | ||
| #define ASTVISITOR_HPP_ | ||
|
|
||
| #include "nodes/class_members/CallDecl.hpp" | ||
| #include "nodes/class_members/DestructorDecl.hpp" | ||
| #include "nodes/class_members/FieldDecl.hpp" | ||
| #include "nodes/class_members/MethodDecl.hpp" | ||
| #include "nodes/class_members/StaticFieldDecl.hpp" | ||
| #include "nodes/decls/ClassDecl.hpp" | ||
| #include "nodes/decls/FunctionDecl.hpp" | ||
| #include "nodes/decls/GlobalVarDecl.hpp" | ||
| #include "nodes/decls/InterfaceDecl.hpp" | ||
| #include "nodes/decls/Module.hpp" | ||
| #include "nodes/decls/TypeAliasDecl.hpp" | ||
| #include "nodes/exprs/Assign.hpp" | ||
| #include "nodes/exprs/Binary.hpp" | ||
| #include "nodes/exprs/Call.hpp" | ||
| #include "nodes/exprs/CastAs.hpp" | ||
| #include "nodes/exprs/Elvis.hpp" | ||
| #include "nodes/exprs/FieldAccess.hpp" | ||
| #include "nodes/exprs/IdentRef.hpp" | ||
| #include "nodes/exprs/IndexAccess.hpp" | ||
| #include "nodes/exprs/NamespaceRef.hpp" | ||
| #include "nodes/exprs/SafeCall.hpp" | ||
| #include "nodes/exprs/TypeTestIs.hpp" | ||
| #include "nodes/exprs/Unary.hpp" | ||
| #include "nodes/exprs/literals/BoolLit.hpp" | ||
| #include "nodes/exprs/literals/CharLit.hpp" | ||
| #include "nodes/exprs/literals/FloatLit.hpp" | ||
| #include "nodes/exprs/literals/IntLit.hpp" | ||
| #include "nodes/exprs/literals/NullLit.hpp" | ||
| #include "nodes/exprs/literals/StringLit.hpp" | ||
| #include "nodes/stmts/BreakStmt.hpp" | ||
| #include "nodes/stmts/ContinueStmt.hpp" | ||
| #include "nodes/stmts/ExprStmt.hpp" | ||
| #include "nodes/stmts/ForStmt.hpp" | ||
| #include "nodes/stmts/IfStmt.hpp" | ||
| #include "nodes/stmts/ReturnStmt.hpp" | ||
| #include "nodes/stmts/UnsafeBlock.hpp" | ||
| #include "nodes/stmts/VarDeclStmt.hpp" | ||
| #include "nodes/stmts/WhileStmt.hpp" | ||
|
|
||
| class AstVisitor { | ||
| public: | ||
| virtual ~AstVisitor() = default; | ||
|
|
||
| // Decls | ||
| virtual void Visit(Module&) = 0; | ||
| virtual void Visit(FunctionDecl&) = 0; | ||
| virtual void Visit(ClassDecl&) = 0; | ||
| virtual void Visit(InterfaceDecl&) = 0; | ||
| virtual void Visit(TypeAliasDecl&) = 0; | ||
| virtual void Visit(GlobalVarDecl&) = 0; | ||
| virtual void Visit(FieldDecl&) = 0; | ||
| virtual void Visit(StaticFieldDecl&) = 0; | ||
| virtual void Visit(MethodDecl&) = 0; | ||
| virtual void Visit(CallDecl&) = 0; | ||
| virtual void Visit(DestructorDecl&) = 0; | ||
|
|
||
| // Stmts | ||
| virtual void Visit(Block&) = 0; | ||
| virtual void Visit(VarDeclStmt&) = 0; | ||
| virtual void Visit(ExprStmt&) = 0; | ||
| virtual void Visit(ReturnStmt&) = 0; | ||
| virtual void Visit(BreakStmt&) = 0; | ||
| virtual void Visit(ContinueStmt&) = 0; | ||
| virtual void Visit(IfStmt&) = 0; | ||
| virtual void Visit(WhileStmt&) = 0; | ||
| virtual void Visit(ForStmt&) = 0; | ||
| virtual void Visit(UnsafeBlock&) = 0; | ||
|
|
||
| // Exprs | ||
| virtual void Visit(Binary&) = 0; | ||
| virtual void Visit(Unary&) = 0; | ||
| virtual void Visit(Assign&) = 0; | ||
| virtual void Visit(Call&) = 0; | ||
| virtual void Visit(FieldAccess&) = 0; | ||
| virtual void Visit(IndexAccess&) = 0; | ||
| virtual void Visit(NamespaceRef&) = 0; | ||
| virtual void Visit(SafeCall&) = 0; | ||
| virtual void Visit(Elvis&) = 0; | ||
| virtual void Visit(CastAs&) = 0; | ||
| virtual void Visit(TypeTestIs&) = 0; | ||
| virtual void Visit(IdentRef&) = 0; | ||
| virtual void Visit(IntLit&) = 0; | ||
| virtual void Visit(FloatLit&) = 0; | ||
| virtual void Visit(StringLit&) = 0; | ||
| virtual void Visit(CharLit&) = 0; | ||
| virtual void Visit(BoolLit&) = 0; | ||
| virtual void Visit(NullLit&) = 0; | ||
| }; | ||
|
|
||
| #endif // ASTVISITOR_HPP_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| #ifndef IASTFACTORY_HPP_ | ||
| #define IASTFACTORY_HPP_ | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include "nodes/class_members/CallDecl.hpp" | ||
| #include "nodes/class_members/DestructorDecl.hpp" | ||
| #include "nodes/class_members/FieldDecl.hpp" | ||
| #include "nodes/class_members/MethodDecl.hpp" | ||
| #include "nodes/class_members/StaticFieldDecl.hpp" | ||
| #include "nodes/decls/ClassDecl.hpp" | ||
| #include "nodes/decls/FunctionDecl.hpp" | ||
| #include "nodes/decls/GlobalVarDecl.hpp" | ||
| #include "nodes/decls/InterfaceDecl.hpp" | ||
| #include "nodes/decls/Module.hpp" | ||
| #include "nodes/decls/TypeAliasDecl.hpp" | ||
| #include "nodes/exprs/Assign.hpp" | ||
| #include "nodes/exprs/Binary.hpp" | ||
| #include "nodes/exprs/Call.hpp" | ||
| #include "nodes/exprs/CastAs.hpp" | ||
| #include "nodes/exprs/Elvis.hpp" | ||
| #include "nodes/exprs/FieldAccess.hpp" | ||
| #include "nodes/exprs/IdentRef.hpp" | ||
| #include "nodes/exprs/IndexAccess.hpp" | ||
| #include "nodes/exprs/NamespaceRef.hpp" | ||
| #include "nodes/exprs/SafeCall.hpp" | ||
| #include "nodes/exprs/TypeTestIs.hpp" | ||
| #include "nodes/exprs/Unary.hpp" | ||
| #include "nodes/exprs/literals/BoolLit.hpp" | ||
| #include "nodes/exprs/literals/CharLit.hpp" | ||
| #include "nodes/exprs/literals/FloatLit.hpp" | ||
| #include "nodes/exprs/literals/IntLit.hpp" | ||
| #include "nodes/exprs/literals/NullLit.hpp" | ||
| #include "nodes/exprs/literals/StringLit.hpp" | ||
| #include "nodes/stmts/BreakStmt.hpp" | ||
| #include "nodes/stmts/ContinueStmt.hpp" | ||
| #include "nodes/stmts/ExprStmt.hpp" | ||
| #include "nodes/stmts/ForStmt.hpp" | ||
| #include "nodes/stmts/IfStmt.hpp" | ||
| #include "nodes/stmts/ReturnStmt.hpp" | ||
| #include "nodes/stmts/UnsafeBlock.hpp" | ||
| #include "nodes/stmts/VarDeclStmt.hpp" | ||
| #include "nodes/stmts/WhileStmt.hpp" | ||
|
|
||
| class IAstFactory { | ||
| public: | ||
| virtual ~IAstFactory() = default; | ||
|
|
||
| virtual std::unique_ptr<Module> MakeModule() = 0; | ||
|
|
||
| virtual std::unique_ptr<FunctionDecl> MakeFunction() = 0; | ||
| virtual std::unique_ptr<ClassDecl> MakeClass() = 0; | ||
| virtual std::unique_ptr<InterfaceDecl> MakeInterface() = 0; | ||
| virtual std::unique_ptr<TypeAliasDecl> MakeTypeAlias() = 0; | ||
| virtual std::unique_ptr<GlobalVarDecl> MakeGlobalVar() = 0; | ||
|
|
||
| virtual std::unique_ptr<FieldDecl> MakeField() = 0; | ||
| virtual std::unique_ptr<StaticFieldDecl> MakeStaticField() = 0; | ||
| virtual std::unique_ptr<MethodDecl> MakeMethod() = 0; | ||
| virtual std::unique_ptr<CallDecl> MakeCallDecl() = 0; | ||
| virtual std::unique_ptr<DestructorDecl> MakeDestructor() = 0; | ||
|
|
||
| virtual std::unique_ptr<Block> MakeBlock() = 0; | ||
| virtual std::unique_ptr<VarDeclStmt> MakeVarDeclStmt() = 0; | ||
| virtual std::unique_ptr<ExprStmt> MakeExprStmt() = 0; | ||
| virtual std::unique_ptr<ReturnStmt> MakeReturnStmt() = 0; | ||
| virtual std::unique_ptr<BreakStmt> MakeBreakStmt() = 0; | ||
| virtual std::unique_ptr<ContinueStmt> MakeContinueStmt() = 0; | ||
| virtual std::unique_ptr<IfStmt> MakeIfStmt() = 0; | ||
| virtual std::unique_ptr<WhileStmt> MakeWhileStmt() = 0; | ||
| virtual std::unique_ptr<ForStmt> MakeForStmt() = 0; | ||
| virtual std::unique_ptr<UnsafeBlock> MakeUnsafeBlock() = 0; | ||
|
|
||
| virtual std::unique_ptr<Binary> MakeBinary(const IBinaryOpTag& op) = 0; | ||
| virtual std::unique_ptr<Unary> MakeUnary(const IUnaryOpTag& op) = 0; | ||
| virtual std::unique_ptr<Assign> MakeAssign(const IAssignOpTag& op) = 0; | ||
| virtual std::unique_ptr<Call> MakeCall() = 0; | ||
| virtual std::unique_ptr<FieldAccess> MakeFieldAccess() = 0; | ||
| virtual std::unique_ptr<IndexAccess> MakeIndexAccess() = 0; | ||
| virtual std::unique_ptr<NamespaceRef> MakeNamespaceRef() = 0; | ||
| virtual std::unique_ptr<SafeCall> MakeSafeCall() = 0; | ||
| virtual std::unique_ptr<Elvis> MakeElvis() = 0; | ||
| virtual std::unique_ptr<CastAs> MakeCastAs() = 0; | ||
| virtual std::unique_ptr<TypeTestIs> MakeTypeTestIs() = 0; | ||
| virtual std::unique_ptr<IdentRef> MakeIdent(std::string name) = 0; | ||
| virtual std::unique_ptr<IntLit> MakeInt(long long v) = 0; | ||
| virtual std::unique_ptr<FloatLit> MakeFloat(long double v) = 0; | ||
| virtual std::unique_ptr<StringLit> MakeString(std::u32string v) = 0; | ||
| virtual std::unique_ptr<CharLit> MakeChar(char32_t v) = 0; | ||
| virtual std::unique_ptr<BoolLit> MakeBool(bool v) = 0; | ||
| virtual std::unique_ptr<NullLit> MakeNull() = 0; | ||
| }; | ||
|
|
||
| #endif // IASTFACTORY_HPP_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| #ifndef ASTNODE_HPP_ | ||
| #define ASTNODE_HPP_ | ||
|
|
||
| class AstVisitor; // forward | ||
|
|
||
| class AstNode { | ||
| public: | ||
| virtual ~AstNode() = default; | ||
|
|
||
| virtual void Accept(AstVisitor& v) = 0; | ||
| }; | ||
|
|
||
| #endif // ASTNODE_HPP_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| #ifndef DECL_HPP_ | ||
| #define DECL_HPP_ | ||
|
|
||
| #include "AstNode.hpp" | ||
|
|
||
| class Decl : public AstNode {}; | ||
|
|
||
| #endif // DECL_HPP_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| #ifndef EXPR_HPP_ | ||
| #define EXPR_HPP_ | ||
|
|
||
| #include "AstNode.hpp" | ||
|
|
||
| class Expr : public AstNode {}; | ||
|
|
||
| #endif // EXPR_HPP_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| #ifndef STMT_HPP_ | ||
| #define STMT_HPP_ | ||
|
|
||
| #include "AstNode.hpp" | ||
|
|
||
| class Stmt : public AstNode {}; | ||
|
|
||
| #endif // STMT_HPP_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #include "CallDecl.hpp" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #ifndef CALLDECL_HPP_ | ||
| #define CALLDECL_HPP_ | ||
|
|
||
| #include <memory> | ||
| #include <vector> | ||
|
|
||
| #include "lib/parser/ast/nodes/base/Decl.hpp" | ||
| #include "lib/parser/ast/nodes/stmts/Block.hpp" | ||
| #include "lib/parser/types/Param.hpp" | ||
| #include "lib/parser/types/TypeReference.hpp" | ||
|
|
||
| class CallDecl : public Decl { | ||
| public: | ||
| void Accept(AstVisitor& v) override; | ||
|
|
||
| private: | ||
| bool is_public_ = true; | ||
| std::vector<Param> params_; | ||
| std::unique_ptr<TypeReference> ret_type_; | ||
| std::unique_ptr<Block> body_; | ||
| }; | ||
|
|
||
| #endif // CALLDECL_HPP_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #include "DestructorDecl.hpp" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| #ifndef DESTRUCTORDECL_HPP_ | ||
| #define DESTRUCTORDECL_HPP_ | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include "lib/parser/ast/nodes/base/Decl.hpp" | ||
| #include "lib/parser/ast/nodes/stmts/Block.hpp" | ||
|
|
||
| class DestructorDecl : public Decl { | ||
| public: | ||
| void Accept(AstVisitor& v) override; | ||
|
|
||
| private: | ||
| bool is_public_ = true; | ||
| std::unique_ptr<Block> body_; | ||
| }; | ||
|
|
||
| #endif // DESTRUCTORDECL_HPP_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #include "FieldDecl.hpp" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| #ifndef FIELDDECL_HPP_ | ||
| #define FIELDDECL_HPP_ | ||
|
|
||
| #include <memory> | ||
| #include <string> | ||
|
|
||
| #include "lib/parser/ast/nodes/base/Decl.hpp" | ||
| #include "lib/parser/types/TypeReference.hpp" | ||
|
|
||
| class FieldDecl : public Decl { | ||
| public: | ||
| void Accept(AstVisitor& v) override; | ||
|
|
||
| private: | ||
| bool is_public_ = true; | ||
| bool is_var_ = false; | ||
| std::string name_; | ||
| TypeReference type_; | ||
| std::unique_ptr<class Expr> init_; // optional | ||
| }; | ||
|
|
||
| #endif // FIELDDECL_HPP_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #include "MethodDecl.hpp" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| #ifndef METHODDECL_HPP_ | ||
| #define METHODDECL_HPP_ | ||
|
|
||
| #include <memory> | ||
| #include <string> | ||
| #include <vector> | ||
|
|
||
| #include "lib/parser/ast/nodes/base/Decl.hpp" | ||
| #include "lib/parser/ast/nodes/stmts/Block.hpp" | ||
| #include "lib/parser/types/Param.hpp" | ||
| #include "lib/parser/types/TypeReference.hpp" | ||
|
|
||
| class MethodDecl : public Decl { | ||
| public: | ||
| void Accept(AstVisitor& v) override; | ||
|
|
||
| private: | ||
| bool is_public_ = true; | ||
| bool is_override_ = false; | ||
| bool is_static_ = false; | ||
| bool is_pure_ = false; | ||
|
|
||
| std::string name; | ||
| std::vector<Param> params; | ||
| std::unique_ptr<TypeReference> ret_type; | ||
| std::unique_ptr<Block> body; // optional | ||
| }; | ||
|
|
||
| #endif // METHODDECL_HPP_ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #include "StaticFieldDecl.hpp" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-public fields naming: should end with an underscore (e.g.
name_)