Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TDP019
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mattias Ajander
TDP019
Commits
5917f2f5
Commit
5917f2f5
authored
1 month ago
by
Mattias Ajander
Browse files
Options
Downloads
Patches
Plain Diff
Changed include path, moved ProgramNode to BlockNode to be used later.
parent
d64e4143
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/ast/BlockNode.h
+7
-3
7 additions, 3 deletions
include/ast/BlockNode.h
include/parser/Parser.h
+4
-4
4 additions, 4 deletions
include/parser/Parser.h
source/ast/BlockNode.cc
+11
-6
11 additions, 6 deletions
source/ast/BlockNode.cc
source/parser/Parser.cc
+3
-3
3 additions, 3 deletions
source/parser/Parser.cc
with
25 additions
and
16 deletions
include/ast/
Program
Node.h
→
include/ast/
Block
Node.h
+
7
−
3
View file @
5917f2f5
#pragma once
#pragma once
#include
"ast/Node.h"
#include
"ast/Node.h"
namespace
funk
namespace
funk
{
{
class
ProgramNode
:
public
Node
class
BlockNode
:
public
Node
{
{
public:
public:
Program
Node
(
const
SourceLocation
&
loc
);
Block
Node
(
const
SourceLocation
&
loc
);
~
Program
Node
();
~
Block
Node
();
void
add
(
Node
*
statement
);
void
add
(
Node
*
statement
);
Vector
<
Node
*>
get_statements
()
const
;
Node
*
evaluate
()
const
override
;
Node
*
evaluate
()
const
override
;
String
to_s
()
const
override
;
String
to_s
()
const
override
;
...
@@ -17,4 +20,5 @@ public:
...
@@ -17,4 +20,5 @@ public:
private:
private:
Vector
<
Node
*>
statements
;
Vector
<
Node
*>
statements
;
};
};
}
// namespace funk
}
// namespace funk
This diff is collapsed.
Click to expand it.
include/parser/Parser.h
+
4
−
4
View file @
5917f2f5
...
@@ -10,11 +10,11 @@
...
@@ -10,11 +10,11 @@
#include
"token/Token.h"
#include
"token/Token.h"
#include
"utils/Common.h"
#include
"utils/Common.h"
#include
"ast/BinaryOpNode.h"
#include
"ast/BlockNode.h"
#include
"ast/LiteralNode.h"
#include
"ast/Node.h"
#include
"ast/Node.h"
#include
"ast/ProgramNode.h"
#include
"ast/expression/BinaryOpNode.h"
#include
"ast/UnaryOpNode.h"
#include
"ast/expression/LiteralNode.h"
#include
"ast/expression/UnaryOpNode.h"
namespace
funk
namespace
funk
{
{
...
...
This diff is collapsed.
Click to expand it.
source/ast/
Program
Node.cc
→
source/ast/
Block
Node.cc
+
11
−
6
View file @
5917f2f5
#include
"ast/
Program
Node.h"
#include
"ast/
Block
Node.h"
namespace
funk
namespace
funk
{
{
ProgramNode
::
Program
Node
(
const
SourceLocation
&
loc
)
:
Node
(
loc
),
statements
{}
{}
BlockNode
::
Block
Node
(
const
SourceLocation
&
loc
)
:
Node
(
loc
),
statements
{}
{}
ProgramNode
::~
Program
Node
()
BlockNode
::~
Block
Node
()
{
{
for
(
Node
*
statement
:
statements
)
{
delete
statement
;
}
for
(
Node
*
statement
:
statements
)
{
delete
statement
;
}
}
}
void
Program
Node
::
add
(
Node
*
statement
)
void
Block
Node
::
add
(
Node
*
statement
)
{
{
statements
.
push_back
(
statement
);
statements
.
push_back
(
statement
);
}
}
Node
*
ProgramNode
::
evaluate
()
const
Vector
<
Node
*>
BlockNode
::
get_statements
()
const
{
return
statements
;
}
Node
*
BlockNode
::
evaluate
()
const
{
{
if
(
cached_eval
)
{
return
cached_eval
;
}
if
(
cached_eval
)
{
return
cached_eval
;
}
...
@@ -23,7 +28,7 @@ Node* ProgramNode::evaluate() const
...
@@ -23,7 +28,7 @@ Node* ProgramNode::evaluate() const
return
cached_eval
=
result
;
return
cached_eval
=
result
;
}
}
String
Program
Node
::
to_s
()
const
String
Block
Node
::
to_s
()
const
{
{
String
repr
{};
String
repr
{};
...
...
This diff is collapsed.
Click to expand it.
source/parser/Parser.cc
+
3
−
3
View file @
5917f2f5
...
@@ -11,9 +11,9 @@ Node* Parser::parse()
...
@@ -11,9 +11,9 @@ Node* Parser::parse()
{
{
LOG_DEBUG
(
"Parse program"
);
LOG_DEBUG
(
"Parse program"
);
ProgramNode
*
program
=
new
Program
Node
(
SourceLocation
(
filename
,
0
,
0
));
BlockNode
*
block
=
new
Block
Node
(
SourceLocation
(
filename
,
0
,
0
));
while
(
!
done
())
{
program
->
add
(
parse_statement
());
}
while
(
!
done
())
{
block
->
add
(
parse_statement
());
}
return
program
;
return
block
;
}
}
Parser
Parser
::
load
(
String
filename
)
Parser
Parser
::
load
(
String
filename
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment