Skip to content

Commit

Permalink
Merge pull request #32 from alexdovzhanyn/linux-runner
Browse files Browse the repository at this point in the history
Linux action runner
  • Loading branch information
alexdovzhanyn authored Sep 30, 2024
2 parents cf40af7 + 1d4cd6a commit 22d972c
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 27 deletions.
42 changes: 19 additions & 23 deletions .github/workflows/cmake-single-platform-linux.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: CMake on a single platform on Linux
name: CMake on Linux

on:
push:
branches: [ "master" ]
branches: ["master"]
pull_request:
branches: [ "master" ]
branches: ["master"]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
Expand Down Expand Up @@ -64,29 +64,26 @@ jobs:
needs: build

steps:
- uses: actions/checkout@v4

- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build
path: ${{ github.workspace }}/build
- uses: actions/checkout@v4

- name: Download Wasmer artifacts
uses: actions/download-artifact@v4
with:
name: wasmer
path: ${{ github.workspace }}/lib/wasmer
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build
path: ${{ github.workspace }}/build

- name: Make LexerTest Executable
run: chmod +x ${{ github.workspace }}/build/LexerTest
- name: Download Wasmer artifacts
uses: actions/download-artifact@v4
with:
name: wasmer
path: ${{ github.workspace }}/lib/wasmer

- name: Output Wasmer directory
run: ls -laR ${{ github.workspace }}/lib/wasmer
- name: Make LexerTest Executable
run: chmod +x ${{ github.workspace }}/build/LexerTest

- name: Run Lexer Test
working-directory: ${{ github.workspace }}/build
run: ./LexerTest
- name: Run Lexer Test
working-directory: ${{ github.workspace }}/build
run: ./LexerTest

parser-test:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -146,7 +143,6 @@ jobs:

steps:
- uses: actions/checkout@v4

- name: Download build artifacts
uses: actions/download-artifact@v4
with:
Expand Down
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

set -e

g++ --version

if [ ! -d "build" ]; then
mkdir build
fi
Expand Down
6 changes: 5 additions & 1 deletion src/compiler/CodeGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
#pragma push_macro("RETURN")
#undef RETURN

#pragma push_macro("RETURN")
#undef RETURN

namespace Theta {
BinaryenModuleRef CodeGen::generateWasmFromAST(shared_ptr<ASTNode> ast) {
BinaryenModuleRef module = initializeWasmModule();
Expand Down Expand Up @@ -93,7 +96,7 @@ namespace Theta {
return generateAssignment(dynamic_pointer_cast<AssignmentNode>(node), module);
} else if (node->getNodeType() == ASTNode::BLOCK) {
return generateBlock(dynamic_pointer_cast<ASTNodeList>(node), module);
} else if (node->getNodeType() == ASTNode::RETURN) {
} else if (node->getNodeType() == Theta::ASTNode::RETURN) {
return generateReturn(dynamic_pointer_cast<ReturnNode>(node), module);
} else if (node->getNodeType() == ASTNode::FUNCTION_DECLARATION) {
// The only time we should get here is if we have a function defined inside a function,
Expand Down Expand Up @@ -1407,4 +1410,5 @@ namespace Theta {
return stream.str();
}
}

#pragma pop_macro("RETURN")
4 changes: 3 additions & 1 deletion src/compiler/CodeGen.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <memory>
#include <functional>
#include "../parser/ast/ASTNode.hpp"
#include "../parser/ast/BinaryOperationNode.hpp"
#include "../parser/ast/UnaryOperationNode.hpp"
Expand All @@ -21,7 +22,8 @@
#include <binaryen-c.h>
#include <set>
#include <unordered_map>
#include <functional>
#include <optional>

using namespace std;

namespace Theta {
Expand Down
1 change: 1 addition & 0 deletions src/compiler/SymbolTable.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <memory>
#include <optional>
#include <map>
#include <optional>
using namespace std;
Expand Down
1 change: 1 addition & 0 deletions src/compiler/SymbolTableStack.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "SymbolTable.hpp"
#include <optional>
#include <stack>

using namespace std;
Expand Down
10 changes: 8 additions & 2 deletions src/parser/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,18 @@ namespace Theta {
shared_ptr<ASTNode> parseControlFlow(shared_ptr<ASTNode> parent) {
if (match(Token::KEYWORD, Lexemes::IF)) {
shared_ptr<ControlFlowNode> cfNode = make_shared<ControlFlowNode>(parent);

shared_ptr<ASTNode> cnd = parseExpression(cfNode);
shared_ptr<ASTNode> expr = parseBlock(cfNode);

vector<pair<shared_ptr<ASTNode>, shared_ptr<ASTNode>>> conditionExpressionPairs = {
make_pair(parseExpression(cfNode), parseBlock(cfNode))
make_pair(cnd, expr)
};

while (match(Token::KEYWORD, Lexemes::ELSE) && match(Token::KEYWORD, Lexemes::IF)) {
conditionExpressionPairs.push_back(make_pair(parseExpression(cfNode), parseBlock(cfNode)));
cnd = parseExpression(cfNode);
expr = parseBlock(cfNode);
conditionExpressionPairs.push_back(make_pair(cnd, expr));
}

// If we just matched an else but no if afterwards. This way it only matches one else block per control flow
Expand Down
3 changes: 3 additions & 0 deletions test/ParserTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,9 @@ TEST_CASE("Parser") {
parser.parse(lexer.tokens, source, "fakeFile.th", filesByCapsuleName)
);

cout << "THE PARSED AST IS: " << endl;
cout << parsedAST->toJSON() << endl;

REQUIRE(parsedAST->getNodeType() == ASTNode::SOURCE);
REQUIRE(parsedAST->getLinks().size() == 0);
REQUIRE(parsedAST->getValue()->getNodeType() == ASTNode::ASSIGNMENT);
Expand Down

0 comments on commit 22d972c

Please sign in to comment.