Skip to content

Commit

Permalink
Merge pull request #117 from stormprograms/classmember
Browse files Browse the repository at this point in the history
fixed issue #108
  • Loading branch information
abbyonstott authored Aug 31, 2019
2 parents db0dc68 + d1e9dc6 commit b46c1fc
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 32 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ jobs:

steps:
- uses: actions/checkout@v1
- name: Configure
run: cmake .
- name: make
run: make
- name: Build
run: |
cd build;
./build.sh
- name: Test
run: |
cd scripts;
./runtests.sh
build_win:
runs-on: windows-latest
Expand All @@ -27,5 +32,5 @@ jobs:
- uses: actions/checkout@v1
- name: Configure
run: cmake . -G "MinGW Makefiles" -DCMAKE_SH="CMAKE_SH-NOTFOUND" -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER=gcc
- name: make
- name: Make
run: mingw32-make
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ CMakeFiles/
CMakeCache.txt
cmake_install.cmake
Makefile
*.ninja
.ninja_deps
.ninja_log
build/stormscript

*.code-workspace
Expand Down
14 changes: 12 additions & 2 deletions example/example.sts
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
in x;
printl x;
type human {
int age;
str name;
}

human h;
h.age: 20;
h.name: "Bob";

if h.age is 20 {
printl h.name, " is ", h.age;
}
3 changes: 0 additions & 3 deletions example/testmod.sts

This file was deleted.

2 changes: 1 addition & 1 deletion src/networking/stsSocket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ stsObject createSocket(string strfamily, string hostname, uint16_t port, stsObje
* It would make sense to combine the commands needed to connect to client/server
* into only a socket.await or socket.connect method respectively
*/
stsObject awaitSocket(stsObject socketObject, string msg, bool output) {
stsObject awaitSocket(stsObject socketObject, string msg, bool output) {
int socketval = std::stoi(socketObject.members[4].val);
int bindval;

Expand Down
2 changes: 1 addition & 1 deletion src/stormscript.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/

void printVersion() {
cout << "StormScript 1.0.0 Release Candidate 2\n";
cout << "StormScript 1.0.0\n";
}

void showhelp() {
Expand Down
19 changes: 6 additions & 13 deletions src/values/compare.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,13 @@ bool condition() {
int opLocation;
int _loc = program.loc;

// The below if statement checks if the value contains a subscript or not by determining the location of the comparison operator
if ((program.expressions[program.loc+1].tktype == IS) || (program.expressions[program.loc+1].tktype == NOT) || (program.expressions[program.loc+1].tktype == GREATER) || (program.expressions[program.loc+1].tktype == GREATEREQ) || (program.expressions[program.loc+1].tktype == LESS) || (program.expressions[program.loc+1].tktype == LESSEQ)) {
comparisonType = program.expressions[program.loc+1].tktype; // set comparison type to condition
opLocation = program.loc+1;
}
else {
int i = program.loc;

while ((program.expressions[i].tktype != IS) && (program.expressions[i].tktype != NOT) && (program.expressions[i].tktype != GREATER) && (program.expressions[i].tktype != GREATEREQ) && (program.expressions[i].tktype != LESS) && (program.expressions[i].tktype != LESSEQ))
i++;
int i = program.loc;

while ((program.expressions[i].tktype != IS) && (program.expressions[i].tktype != NOT) && (program.expressions[i].tktype != GREATER) && (program.expressions[i].tktype != GREATEREQ) && (program.expressions[i].tktype != LESS) && (program.expressions[i].tktype != LESSEQ))
i++;

comparisonType = program.expressions[i].tktype;
opLocation = i;
}
comparisonType = program.expressions[i].tktype;
opLocation = i;

program_t program_old = program; // create more isolated expressions to get the value to compare
program.expressions = {};
Expand Down
20 changes: 13 additions & 7 deletions src/values/getvals.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,17 @@ stsvars getval() {
*/

stsvars v;
bool dotCompare = false; // dot operations take up 2 extra expression slots

if (program.expressions[program.loc+1].tktype == DOT && program.expressions[program.loc+3].tktype != COMMA && program.expressions[program.loc+3].t != ENDEXPR
&& program.expressions.size() > program.loc+3) {
dotCompare = true;
program.loc += 2;
}

bool operation = ((program.expressions[program.loc+1].t == TOKEN) &&
(program.expressions[program.loc+1].tktype != COMMA) && (program.expressions[program.loc+1].tktype != COLON) && (program.expressions[program.loc+1].tktype != OPENCURL) && (program.expressions[program.loc+1].tktype != CLOSEDBRACKET) &&
(program.expressions[program.loc+1].tktype != DOT || (
(program.expressions[program.loc+3].tktype == IS) || (program.expressions[program.loc+3].tktype == NOT) || // DOT and operation
(program.expressions[program.loc+3].tktype == LESS) || program.expressions[program.loc+3].tktype == LESSEQ ||
program.expressions[program.loc+3].tktype == GREATER || program.expressions[program.loc+3].tktype == GREATEREQ)
) &&
(program.expressions[program.loc+1].tktype != COMMA) && (program.expressions[program.loc+1].tktype != COLON) && (program.expressions[program.loc+1].tktype != OPENCURL) && (program.expressions[program.loc+1].tktype != CLOSEDBRACKET) &&
(program.expressions[program.loc+1].tktype != DOT) &&
(program.expressions.size() > program.loc+1));

switch (operation) {
Expand Down Expand Up @@ -271,7 +274,10 @@ stsvars getval() {
case GREATEREQ:
case LESS:
case LESSEQ:
// subtract 2 for condition function to get values
if (dotCompare) program.loc -= 2;
v.val = ((condition()) ? "true" : "false");

if (program.expressions[program.loc].tktype == TERNARY1) {
/*
For ternary, we can assume that it is structured like this:
Expand Down Expand Up @@ -306,4 +312,4 @@ stsvars getval() {
break;
}
return v;
}
}

0 comments on commit b46c1fc

Please sign in to comment.