Skip to content

Commit

Permalink
repl and build info complete.
Browse files Browse the repository at this point in the history
  • Loading branch information
jweinst1 committed Jun 11, 2018
1 parent 433b69a commit f9f0577
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 34 deletions.
12 changes: 12 additions & 0 deletions include/LangInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef LANG_INFO_H
#define LANG_INFO_H

// Header that contains macro string literals for information about the Wind Language

#define LangInfo_VERSION "0.0.1"

#define LangInfo_NAME "Wind"

#define LangInfo_REPL_INS "The Wind Programming Language REPL\nTo exit, simply enter 'exit'.\n"

#endif
6 changes: 1 addition & 5 deletions include/WindRun.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,9 @@ int WindRun_load(const char** code);
// When found, does a goto to TRANS_TO_LOAD to switch state.
int WindRun_command(const char** code);

// Runs the code as a complete portion of source code.
// Runs a string of code
// Will execute any lasting commands and print any errors once
// the end of the string is reached.
void WindRun_code(const char* code);

// Runs the code as continuous incoming stream of code chunks
// Does not force lasting commands or print errors once a single code chunk is done.
void WindRun_continuous(const char* code);

#endif
31 changes: 3 additions & 28 deletions src/code/WindRun.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,17 +315,16 @@ int WindRun_command(const char** code)
break;

case '\0':
if(WindState_has_cmd()) goto TRANS_TO_LOAD;
else return 1;
goto TRANS_TO_LOAD;
default:
WindState_write_err("Expected command symbol, found '%c'", **code);
return 0;
}
}
goto TRANS_TO_LOAD;
TRANS_TO_LOAD:
WindState_set_mode(WindMode_load);
return 1;
if(WindState_has_cmd()) WindState_set_mode(WindMode_load);
else return 1;
}

void WindRun_code(const char* code)
Expand Down Expand Up @@ -358,27 +357,3 @@ void WindRun_code(const char* code)
return;
}
}

void WindRun_continuous(const char* code)
{
while(*code)
{
if(WindState_has_err())
{
WindState_print_err();
return;
}
switch(WindState_get_mode())
{
case WindMode_command:
WindRun_command(&code);
break;
case WindMode_load:
WindRun_load(&code);
break;
case WindMode_exec:
WindRun_exec(&code);
break;
}
}
}
5 changes: 4 additions & 1 deletion src/util/IOUtil.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "IOUtil.h"
#include "LangInfo.h"



static inline int
Expand Down Expand Up @@ -98,6 +100,7 @@ void IOUtil_repl(void)
{
int running = 1;
char replBuf[IOUtil_REPL_SIZE];
printf("%s - Version (%s)\n%s", LangInfo_NAME, LangInfo_VERSION, LangInfo_REPL_INS);
while(running)
{
printf(IOUtil_REPL_PROMPT);
Expand All @@ -109,7 +112,7 @@ void IOUtil_repl(void)
}
else
{
WindRun_continuous(replBuf);
WindRun_code(replBuf);
}
}
}
Expand Down

0 comments on commit f9f0577

Please sign in to comment.