Skip to content

Commit

Permalink
Merge pull request #33 from stormprograms/fixcond
Browse files Browse the repository at this point in the history
Fixed crash on else statement after new line
  • Loading branch information
abbyonstott authored Jan 14, 2019
2 parents 830b795 + 6d03352 commit caff4ef
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 13 deletions.
10 changes: 6 additions & 4 deletions docs/style.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ C++ has the strictest rules when it comes to styling as it makes up the majority
## Includes
**YOU MUST FOLLOW THIS**

All includes must go at the top of [stsclasses.h](/core/stsclasses.h).
All includes must go at the top of [includes.h](/src/include/includes.h).

## Formatting
The general rule of formatting here is not to use more lines than you need to make it readable.
Expand All @@ -32,7 +32,7 @@ for (int i = 0; i<=number; i++) {
}
```

If you are using multiple lines in your scope, always include braces.
If you are using multiple lines in your scope, always include an opening brace on the same line.

```cpp
for (int i = 0; i<=number; i++) {
Expand All @@ -43,12 +43,14 @@ for (int i = 0; i<=number; i++) {
rather than
```cpp
for (int i = 0; i<=number; i++)
{
cout << "Hi there.\n";
foo(bar);
}
```
**Always put braces on the same line as the statement with a space separating them**

## SubScripts
## Sub Scripts

Use `string::back()` and `string::front()` when applicable

Expand All @@ -58,7 +60,7 @@ if ((prs[y].back()==':') || (prs[y+4]==":")) {
...
}
```
source: [man.cc](/values/man.cc)
source: [man.cc](/src/values/man.cc)


## Keywords
Expand Down
10 changes: 9 additions & 1 deletion example/example.sts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
do{
x: 4;
x-: 3;
printl "Hello, World!";

if x is 3 {
printl "hi";
}else if x is 4 {
printl "hi there";
}else {
printl "bye";
}
}
2 changes: 1 addition & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: stormscript # you probably want to 'snapcraft register <name>'
version: 'v0.4.0' # just for humans, typically '1.2+git' or '1.3.2'
version: 'v0.4.1' # just for humans, typically '1.2+git' or '1.3.2'
summary: StormScript is an easy to use, open-source scripting language # 79 char long summary
description: |
StormScript is an open source scripting language. StormScript was created on the belief that a good scripting language can be both powerful and easily readable and learnable.
Expand Down
2 changes: 1 addition & 1 deletion src/core/stormscript.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ int main(int argc, char *argv[]) {

if (argc != 1) {
if (string(argv[1])=="--version"){
cout << "StormScript v0.4.0 \"Dragon Fruit\"\n";
cout << "StormScript v0.4.1 \"Dragon Fruit\"\n";
}
else if ((string(argv[1])=="--help") || (string(argv[1])=="-h")) {
cout << "Usage: stormscript [file|options]\n";
Expand Down
1 change: 0 additions & 1 deletion src/interpreter/exec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ void sts::exec(int *x, int function, std::vector<stsclasstype> *pclasstypes, std
while (prs[y] != "}") {
y++;
}
y--;
}
else if (prs[y]=="sys")
sys(&y, vars);
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/helloworld/helloworld.stslib
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
lib system;

do{
str cmd: arg[1];
cmd: arg[1];

if cmd is "out"{
printl "Hello, World!";
Expand Down
7 changes: 3 additions & 4 deletions src/values/if.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ void sts::ifs(int *line, int *endr, std::vector<stsvars> vars) {
while (prs[y] != "}") {
y++;
if (prs[y+1] == "else") {
if (prs[y+1] == "if") {
y++;
if (prs[y+2] == "if") {
y+= 2;
ifs(&y, &endreq, vars);
break;
}
Expand All @@ -23,9 +23,8 @@ void sts::ifs(int *line, int *endr, std::vector<stsvars> vars) {
}
}
}
else{
else
y+=3;
}

*line = y;
*endr = endreq;
Expand Down

0 comments on commit caff4ef

Please sign in to comment.