Skip to content

Commit

Permalink
system includes before user includes, and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jpoirier committed Jun 17, 2015
1 parent 96ee5bc commit 97fbbaa
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 29 deletions.
1 change: 0 additions & 1 deletion expression.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* picoc expression evaluator - a stack-based expression evaluation system
* which handles operator precedence */

#include "interpreter.h"


Expand Down
6 changes: 2 additions & 4 deletions parse.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
/* picoc parser - parses source and executes statements */

#include "picoc.h"
#include "interpreter.h"

static enum ParseResult ParseStatementMaybeRun(struct ParseState *Parser,
int Condition, int CheckTrailingSemicolon);
static int ParseCountParams(struct ParseState *Parser);
static int ParseArrayInitialiser(struct ParseState *Parser, struct Value *NewVariable,
int DoAssignment);
static int ParseArrayInitialiser(struct ParseState *Parser,
struct Value *NewVariable, int DoAssignment);
static void ParseDeclarationAssignment(struct ParseState *Parser,
struct Value *NewVariable, int DoAssignment);
static int ParseDeclaration(struct ParseState *Parser, enum LexToken Token);
Expand Down Expand Up @@ -379,7 +378,6 @@ int ParseDeclaration(struct ParseState *Parser, enum LexToken Token)
Token = LexGetToken(Parser, NULL, false);
if (Token == TokenComma)
LexGetToken(Parser, NULL, true);

} while (Token == TokenComma);

return true;
Expand Down
11 changes: 6 additions & 5 deletions picoc.c
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
/* picoc main program - this varies depending on your operating system and
* how you're using picoc */
/* platform-dependent code for running programs is in this file */
#if defined(UNIX_HOST) || defined(WIN32)
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#endif

/* include only picoc.h here - should be able to use it with only the
external interfaces, no internals from interpreter.h */
#include "picoc.h"

/* platform-dependent code for running programs is in this file */

#if defined(UNIX_HOST) || defined(WIN32)
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include "LICENSE.h"

/* Override via STACKSIZE environment variable */
Expand Down
10 changes: 4 additions & 6 deletions picoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#ifndef PICOC_H
#define PICOC_H


/* picoc version number */
#ifdef VER
/* VER is the git hash number, obtained via the Makefile */
Expand All @@ -13,13 +14,10 @@

#include "interpreter.h"


#if defined(UNIX_HOST) || defined(WIN32)
#include <setjmp.h>

/* this has to be a macro, otherwise errors will occur due to the stack being corrupt */
/* this has to be a macro, otherwise errors will occur due to
the stack being corrupt */
#define PicocPlatformSetExitPoint(pc) setjmp((pc)->PicocExitBuf)
#endif


/* parse.c */
extern void PicocParse(Picoc *pc, const char *FileName, const char *Source,
Expand Down
3 changes: 1 addition & 2 deletions platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,7 @@ void PlatformVPrintf(IOFILE *Stream, const char *Format, va_list Args)
default:
break;
}
}
else
} else
PrintCh(*FPos, Stream);
}
}
Expand Down
25 changes: 14 additions & 11 deletions platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
#include <math.h>
#include <stdbool.h>

/* host platform includes */
#ifdef UNIX_HOST
# include <stdint.h>
# include <unistd.h>
#elif defined(WIN32) /*(predefined on MSVC)*/
#else
# error ***** A platform must be explicitly defined! *****
#endif


/* configurable options */
/* select your host type (or do it in the Makefile):
#define UNIX_HOST
Expand All @@ -22,6 +32,10 @@
*/
#define USE_READLINE

#if defined(WIN32) /*(predefined on MSVC)*/
#undef USE_READLINE
#endif

/* undocumented, but probably useful */
#undef DEBUG_HEAP
#undef DEBUG_EXPRESSIONS
Expand Down Expand Up @@ -52,17 +66,6 @@
#define INTERACTIVE_PROMPT_STATEMENT "picoc> "
#define INTERACTIVE_PROMPT_LINE " > "


/* host platform includes */
#ifdef UNIX_HOST
# include <stdint.h>
# include <unistd.h>
#elif defined(WIN32) /*(predefined on MSVC)*/
#undef USE_READLINE
#else
# error ***** A platform must be explicitly defined! *****
#endif

extern jmp_buf ExitBuf;

#endif /* PLATFORM_H */

0 comments on commit 97fbbaa

Please sign in to comment.