system includes before user includes, and cleanup
This commit is contained in:
parent
96ee5bc665
commit
97fbbaaf8f
|
@ -1,6 +1,5 @@
|
|||
/* picoc expression evaluator - a stack-based expression evaluation system
|
||||
* which handles operator precedence */
|
||||
|
||||
#include "interpreter.h"
|
||||
|
||||
|
||||
|
|
6
parse.c
6
parse.c
|
@ -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);
|
||||
|
@ -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;
|
||||
|
|
11
picoc.c
11
picoc.c
|
@ -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 */
|
||||
|
|
10
picoc.h
10
picoc.h
|
@ -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 */
|
||||
|
@ -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,
|
||||
|
|
|
@ -249,8 +249,7 @@ void PlatformVPrintf(IOFILE *Stream, const char *Format, va_list Args)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
PrintCh(*FPos, Stream);
|
||||
}
|
||||
}
|
||||
|
|
25
platform.h
25
platform.h
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
|
Loading…
Reference in a new issue