Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
jweinst1 committed May 23, 2018
1 parent 1593515 commit 3d10e38
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
10 changes: 5 additions & 5 deletions include/WindRun.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
#define WIND_RUN_H

#include <stdio.h>
#include "WindStream.h"
#include "WindData.h"
#include "WindExec.h"
#include "WindLoad.h"

// central header that handles running of code


int WindRun_exec(WindStream* ws, const char** code);
int WindRun_exec(const char** code);

int WindRun_load(WindStream* ws, const char** code);
int WindRun_load(const char** code);

// Parses the source code for a command name.
// When found, does a goto to TRANS_TO_LOAD to switch state.
int WindRun_command(WindStream* ws, const char** code);
int WindRun_command(const char** code);

// Top level function that takes a stream and runs textual source code on it.
void WindRun_code(WindStream* ws, const char* code);
void WindRun_code(const char* code);

#endif
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
26 changes: 13 additions & 13 deletions src/code/WindRun.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <ctype.h>
#include "WindRun.h"

int WindRun_exec(WindStream* ws, const char** code)
int WindRun_exec(const char** code)
{
switch(ws->command)
{
Expand All @@ -26,7 +26,7 @@ int WindRun_exec(WindStream* ws, const char** code)
return 1;
}

int WindRun_load(WindStream* ws, const char** code)
int WindRun_load(const char** code)
{
while(**code)
{
Expand Down Expand Up @@ -148,7 +148,7 @@ int WindRun_load(WindStream* ws, const char** code)
return 1;
}

int WindRun_command(WindStream* ws, const char** code)
int WindRun_command(const char** code)
{
while(**code)
{
Expand Down Expand Up @@ -265,33 +265,33 @@ int WindRun_command(WindStream* ws, const char** code)
return 1;
}

void WindRun_code(WindStream* ws, const char* code)
void WindRun_code(const char* code)
{
while(*code)
{
if(ws->hasErr)
if(WindState_has_err())
{
WindStream_print_err(ws);
WindState_print_err();
return;
}
switch(ws->state)
switch(WindState_get_cmd())
{
case StreamState_command:
case WindMode_command:
WindRun_command(ws, &code);
break;
case StreamState_load:
case WindMode_load:
WindRun_load(ws, &code);
break;
case StreamState_exec:
case WindMode_exec:
WindRun_exec(ws, &code);
break;
}
}
// Executes any lasting commands, if null char is reached first.
if(ws->command != WindCommand_null) WindRun_exec(ws, &code);
if(ws->hasErr)
if(WindState_has_cmd()) WindRun_exec(ws, &code);
if(WindState_has_err())
{
WindStream_print_err(ws);
WindState_print_err();
return;
}
}
2 changes: 1 addition & 1 deletion src/flow/WindState.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ WindCommand WindState_get_cmd(void)

int WindState_has_cmd(void)
{
return WindState_COMMAND == WindCommand_null;
return WindState_COMMAND != WindCommand_null;
}

void WindState_print_cmd(void)
Expand Down

0 comments on commit 3d10e38

Please sign in to comment.