Compare commits
1 Commits
master
...
955e75addb
| Author | SHA1 | Date | |
|---|---|---|---|
| 955e75addb |
@@ -75,7 +75,7 @@ build
|
||||
- [x] String operations
|
||||
- [x] Maths
|
||||
- [x] Comparisions
|
||||
- [x] Type conversions
|
||||
- [ ] Type conversions
|
||||
- [x] Functions
|
||||
- [x] Define functions
|
||||
- [x] Call functions
|
||||
@@ -83,7 +83,7 @@ build
|
||||
- [x] Arguments for functions
|
||||
- [x] Jumping within functions
|
||||
- [x] Custom data structures
|
||||
- [x] Working with external libraries
|
||||
- [ ] Working with external libraries
|
||||
|
||||
## Debugger
|
||||
|
||||
|
||||
@@ -362,23 +362,3 @@ Looks in the path $GROUND_LIBS/`$libraryName`.grnd for the library. ($GROUND_LIB
|
||||
Attempts to import a shared library written in a compiled language like C or C++ for usage within the current program.
|
||||
|
||||
Looks in the path $GROUND_LIBS/`$libraryName`.so for the library. ($GROUND_LIBS is a system environment variable.)
|
||||
|
||||
### Data Structures
|
||||
|
||||
#### struct -structName
|
||||
|
||||
Creates a new struct which can be initialised. Until the endstruct keyword, the only valid instructions are init, set, fun, endfun, struct, and endstruct.
|
||||
|
||||
Any value created inside the struct will be added to the struct.
|
||||
|
||||
#### endstruct
|
||||
|
||||
Ends the creation of a struct.
|
||||
|
||||
#### getfield $object &fieldName &outputVar
|
||||
|
||||
Gets a field from an initialised object. fieldName must be a valid name of a field in the object. Errors if the field does not exist.
|
||||
|
||||
#### setfield &object &fieldName $value
|
||||
|
||||
Sets a field to a new value in the object. The value must be of the same type as the field's old value.
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#ifndef LIBGROUND_H
|
||||
#define LIBGROUND_H
|
||||
#define MAX_ID_LEN 64
|
||||
|
||||
/*
|
||||
* groundvm.h
|
||||
@@ -14,9 +13,8 @@
|
||||
#include <stdarg.h>
|
||||
#include <uthash.h>
|
||||
|
||||
|
||||
typedef enum GroundInstType {
|
||||
IF, JUMP, END, INPUT, PRINT, PRINTLN, SET, GETTYPE, EXISTS, SETLIST, SETLISTAT, GETLISTAT, GETLISTSIZE, LISTAPPEND, GETSTRSIZE, GETSTRCHARAT, ADD, SUBTRACT, MULTIPLY, DIVIDE, EQUAL, INEQUAL, NOT, GREATER, LESSER, STOI, STOD, ITOC, CTOI, TOSTRING, FUN, RETURN, ENDFUN, PUSHARG, CALL, STRUCT, ENDSTRUCT, INIT, GETFIELD, SETFIELD, USE, EXTERN, CREATELABEL, PAUSE, DROP, ERRORCMD
|
||||
IF, JUMP, END, INPUT, PRINT, PRINTLN, SET, GETTYPE, EXISTS, SETLIST, SETLISTAT, GETLISTAT, GETLISTSIZE, LISTAPPEND, GETSTRSIZE, GETSTRCHARAT, ADD, SUBTRACT, MULTIPLY, DIVIDE, EQUAL, INEQUAL, NOT, GREATER, LESSER, STOI, STOD, TOSTRING, FUN, RETURN, ENDFUN, PUSHARG, CALL, STRUCT, ENDSTRUCT, INIT, GETFIELD, SETFIELD, USE, EXTERN, CREATELABEL, PAUSE, DROP, ERRORCMD
|
||||
} GroundInstType;
|
||||
|
||||
typedef enum GroundValueType {
|
||||
@@ -33,7 +31,6 @@ typedef enum ListAccessStatus {
|
||||
|
||||
struct GroundValue;
|
||||
struct GroundFunction;
|
||||
struct GroundStruct;
|
||||
|
||||
struct List;
|
||||
|
||||
@@ -62,7 +59,7 @@ typedef struct GroundError {
|
||||
typedef struct GroundValue {
|
||||
GroundValueType type;
|
||||
struct GroundStruct* customType;
|
||||
struct {
|
||||
union {
|
||||
int64_t intVal;
|
||||
double doubleVal;
|
||||
char* stringVal;
|
||||
@@ -166,24 +163,6 @@ typedef struct GroundObject {
|
||||
GroundObjectField* fields;
|
||||
} GroundObject;
|
||||
|
||||
typedef struct GroundLabel {
|
||||
char id[MAX_ID_LEN];
|
||||
int lineNum;
|
||||
UT_hash_handle hh;
|
||||
} GroundLabel;
|
||||
|
||||
typedef struct GroundVariable {
|
||||
char id[MAX_ID_LEN];
|
||||
GroundValue value;
|
||||
UT_hash_handle hh;
|
||||
} GroundVariable;
|
||||
|
||||
typedef struct GroundScope {
|
||||
GroundLabel** labels;
|
||||
GroundVariable** variables;
|
||||
bool isMainScope;
|
||||
} GroundScope;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -199,8 +178,6 @@ void groundAddValueToInstruction(GroundInstruction* inst, GroundValue value);
|
||||
void groundAddReferenceToInstruction(GroundInstruction* inst, GroundArg value);
|
||||
GroundArg groundCreateReference(GroundArgType type, char* ref);
|
||||
|
||||
void groundAddValueToScope(GroundScope* gs, const char* name, GroundValue value);
|
||||
|
||||
GroundValue groundCreateValue(GroundValueType type, ...);
|
||||
|
||||
GroundProgram groundParseFile(const char* code);
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifndef _WIN32
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
#include <stdarg.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -445,7 +443,6 @@ GroundStruct parseStruct(GroundProgram* in, GroundScope* scope, size_t errorOffs
|
||||
addInstructionToProgram(&gp, in->instructions[i]);
|
||||
i++;
|
||||
}
|
||||
i--;
|
||||
|
||||
GroundFunction* function = parseFunction(&gp, errorOffset);
|
||||
function->startLine = i;
|
||||
@@ -512,7 +509,6 @@ GroundValue interpretGroundProgram(GroundProgram* in, GroundScope* inScope) {
|
||||
addInstructionToProgram(&gp, in->instructions[i]);
|
||||
i++;
|
||||
}
|
||||
i--;
|
||||
|
||||
GroundFunction* function = parseFunction(&gp, errorOffset);
|
||||
function->startLine = i;
|
||||
@@ -550,7 +546,6 @@ GroundValue interpretGroundProgram(GroundProgram* in, GroundScope* inScope) {
|
||||
addInstructionToProgram(&gp, in->instructions[i]);
|
||||
i++;
|
||||
}
|
||||
i--;
|
||||
|
||||
GroundValue gv = {
|
||||
.type = STRUCTVAL,
|
||||
@@ -1109,7 +1104,7 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
|
||||
if (in->args.args[1].type != DIRREF) {
|
||||
runtimeError(ARG_TYPE_MISMATCH, "Expecting a DirectRef for arg 2", in, currentInstruction);
|
||||
}
|
||||
addVariable(scope->variables, in->args.args[1].value.refName, createIntGroundValue(atoll(in->args.args[0].value.value.data.stringVal)));
|
||||
addVariable(scope->variables, in->args.args[2].value.refName, createIntGroundValue(atoll(in->args.args[0].value.value.data.stringVal)));
|
||||
break;
|
||||
}
|
||||
case STOD: {
|
||||
@@ -1125,39 +1120,7 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
|
||||
if (in->args.args[1].type != DIRREF) {
|
||||
runtimeError(ARG_TYPE_MISMATCH, "Expecting a DirectRef for arg 2", in, currentInstruction);
|
||||
}
|
||||
addVariable(scope->variables, in->args.args[1].value.refName, createDoubleGroundValue(atof(in->args.args[0].value.value.data.stringVal)));
|
||||
break;
|
||||
}
|
||||
case ITOC: {
|
||||
if (in->args.length < 2) {
|
||||
runtimeError(TOO_FEW_ARGS, "Expecting 2 args", in, currentInstruction);
|
||||
}
|
||||
if (in->args.length > 2) {
|
||||
runtimeError(TOO_MANY_ARGS, "Expecting 2 args", in, currentInstruction);
|
||||
}
|
||||
if (in->args.args[0].type != VALUE || in->args.args[0].value.value.type != INT) {
|
||||
runtimeError(ARG_TYPE_MISMATCH, "Expecting an Int for arg 1", in, currentInstruction);
|
||||
}
|
||||
if (in->args.args[1].type != DIRREF) {
|
||||
runtimeError(ARG_TYPE_MISMATCH, "Expecting a DirectRef for arg 2", in, currentInstruction);
|
||||
}
|
||||
addVariable(scope->variables, in->args.args[1].value.refName, createCharGroundValue((char)in->args.args[0].value.value.data.intVal));
|
||||
break;
|
||||
}
|
||||
case CTOI: {
|
||||
if (in->args.length < 2) {
|
||||
runtimeError(TOO_FEW_ARGS, "Expecting 2 args", in, currentInstruction);
|
||||
}
|
||||
if (in->args.length > 2) {
|
||||
runtimeError(TOO_MANY_ARGS, "Expecting 2 args", in, currentInstruction);
|
||||
}
|
||||
if (in->args.args[0].type != VALUE || in->args.args[0].value.value.type != CHAR) {
|
||||
runtimeError(ARG_TYPE_MISMATCH, "Expecting a Char for arg 1", in, currentInstruction);
|
||||
}
|
||||
if (in->args.args[1].type != DIRREF) {
|
||||
runtimeError(ARG_TYPE_MISMATCH, "Expecting a DirectRef for arg 2", in, currentInstruction);
|
||||
}
|
||||
addVariable(scope->variables, in->args.args[1].value.refName, createIntGroundValue((int)in->args.args[0].value.value.data.charVal));
|
||||
addVariable(scope->variables, in->args.args[1].value.refName, createIntGroundValue(atof(in->args.args[0].value.value.data.stringVal)));
|
||||
break;
|
||||
}
|
||||
case TOSTRING: {
|
||||
@@ -1174,53 +1137,57 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
|
||||
runtimeError(ARG_TYPE_MISMATCH, "Expecting a DirectRef for arg 2", in, currentInstruction);
|
||||
}
|
||||
GroundValue* value = &in->args.args[0].value.value;
|
||||
char buf[256];
|
||||
switch (value->type) {
|
||||
case INT: {
|
||||
snprintf(buf, sizeof(buf) * 256, "%" PRId64, value->data.intVal);
|
||||
char* buf = malloc(sizeof(char) * 256);
|
||||
snprintf(buf, sizeof(char) * 256, "%" PRId64, value->data.intVal);
|
||||
addVariable(scope->variables, in->args.args[1].value.refName, createStringGroundValue(buf));
|
||||
break;
|
||||
}
|
||||
case DOUBLE: {
|
||||
snprintf(buf, sizeof(buf) * 256, "%f", value->data.doubleVal);
|
||||
char* buf = malloc(sizeof(char) * 256);
|
||||
snprintf(buf, sizeof(char) * 256, "%f", value->data.doubleVal);
|
||||
addVariable(scope->variables, in->args.args[1].value.refName, createStringGroundValue(buf));
|
||||
break;
|
||||
}
|
||||
case STRING: {
|
||||
snprintf(buf, sizeof(buf), "%s", value->data.stringVal);
|
||||
addVariable(scope->variables, in->args.args[1].value.refName, createStringGroundValue(value->data.stringVal));
|
||||
break;
|
||||
}
|
||||
case CHAR: {
|
||||
char* buf = malloc(sizeof(char) * 2);
|
||||
buf[0] = value->data.charVal;
|
||||
buf[1] = '\0';
|
||||
addVariable(scope->variables, in->args.args[1].value.refName, createStringGroundValue(buf));
|
||||
break;
|
||||
}
|
||||
case BOOL: {
|
||||
if (value->data.boolVal) {
|
||||
snprintf(buf, sizeof(buf), "true");
|
||||
addVariable(scope->variables, in->args.args[1].value.refName, createStringGroundValue("true"));
|
||||
} else {
|
||||
snprintf(buf, sizeof(buf), "false");
|
||||
addVariable(scope->variables, in->args.args[1].value.refName, createStringGroundValue("false"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LIST: {
|
||||
snprintf(buf, sizeof(buf), "<list>");
|
||||
addVariable(scope->variables, in->args.args[1].value.refName, createStringGroundValue("<list>"));
|
||||
break;
|
||||
}
|
||||
case FUNCTION: {
|
||||
snprintf(buf, sizeof(buf), "<function>");
|
||||
addVariable(scope->variables, in->args.args[1].value.refName, createStringGroundValue("<function>"));
|
||||
break;
|
||||
}
|
||||
case CUSTOM: {
|
||||
snprintf(buf, sizeof(buf), "<custom>");
|
||||
addVariable(scope->variables, in->args.args[1].value.refName, createStringGroundValue("<custom>"));
|
||||
break;
|
||||
}
|
||||
case NONE:
|
||||
default: {
|
||||
snprintf(buf, sizeof(buf), "<default>");
|
||||
addVariable(scope->variables, in->args.args[1].value.refName, createStringGroundValue("<default>"));
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
addVariable(scope->variables, in->args.args[1].value.refName, createStringGroundValue(buf));
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -1927,10 +1894,6 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
|
||||
}
|
||||
|
||||
case EXTERN: {
|
||||
#ifdef _WIN32
|
||||
runtimeError(FIXME, "No Windows support for extern, sucker", in, currentInstruction);
|
||||
#endif
|
||||
#ifndef _WIN32
|
||||
if (in->args.length < 1) {
|
||||
runtimeError(TOO_FEW_ARGS, "Expecting 1 arg", in, currentInstruction);
|
||||
}
|
||||
@@ -1980,7 +1943,6 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
|
||||
}
|
||||
|
||||
initFn(scope);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
30
src/main.c
30
src/main.c
@@ -1,7 +1,6 @@
|
||||
#include "parser.h"
|
||||
#include "interpreter.h"
|
||||
#include "compiler.h"
|
||||
#include "types.h"
|
||||
#include <stdio.h>
|
||||
|
||||
char* getFileContents(const char* filename) {
|
||||
@@ -41,6 +40,19 @@ char* getFileContents(const char* filename) {
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
/*
|
||||
if (argc < 2) {
|
||||
printf("Usage: ground [file]\n");
|
||||
exit(1);
|
||||
}
|
||||
char* file = getFileContents(argv[1]);
|
||||
GroundProgram program = parseFile(file);
|
||||
free(file);
|
||||
char* compiled = compileGroundProgram(&program);
|
||||
printf("%s\n", compiled);
|
||||
interpretGroundProgram(&program, NULL);
|
||||
*/
|
||||
|
||||
if (argc < 2) {
|
||||
printf("Usage: %s <file> [-c] [--compile] [-h] [--help]\n", argv[0]);
|
||||
exit(1);
|
||||
@@ -48,7 +60,7 @@ int main(int argc, char** argv) {
|
||||
|
||||
bool compile = false;
|
||||
char* fileName = NULL;
|
||||
List groundArgs = createList();
|
||||
|
||||
for (int i = 1; i < argc; i++) {
|
||||
if (strcmp("--compile", argv[i]) == 0 || strcmp("-c", argv[i]) == 0) {
|
||||
compile = true;
|
||||
@@ -61,11 +73,7 @@ int main(int argc, char** argv) {
|
||||
printf(" -h or --help: Shows this help message\n");
|
||||
exit(0);
|
||||
} else {
|
||||
if (fileName == NULL) {
|
||||
fileName = argv[i];
|
||||
} else {
|
||||
appendToList(&groundArgs, createStringGroundValue(argv[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,14 +91,6 @@ int main(int argc, char** argv) {
|
||||
char* compiled = compileGroundProgram(&program);
|
||||
printf("%s\n", compiled);
|
||||
} else {
|
||||
GroundVariable* variables = NULL;
|
||||
GroundLabel* labels = NULL;
|
||||
|
||||
GroundScope scope;
|
||||
scope.variables = &variables;
|
||||
scope.labels = &labels;
|
||||
scope.isMainScope = true;
|
||||
addVariable(scope.variables, "CMDLINE_ARGS", createListGroundValue(groundArgs));
|
||||
interpretGroundProgram(&program, &scope);
|
||||
interpretGroundProgram(&program, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
21
src/parser.c
21
src/parser.c
@@ -5,25 +5,6 @@
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
size_t strnlen(const char *src, size_t n) {
|
||||
size_t len = 0;
|
||||
while (len < n && src[len])
|
||||
len++;
|
||||
return len;
|
||||
}
|
||||
|
||||
char* strndup(const char *s, size_t n) {
|
||||
size_t len = strnlen(s, n);
|
||||
char *p = malloc(len + 1);
|
||||
if (p) {
|
||||
memcpy(p, s, len);
|
||||
p[len] = '\0';
|
||||
}
|
||||
return p;
|
||||
}
|
||||
#endif
|
||||
|
||||
GroundProgram createGroundProgram() {
|
||||
GroundProgram gp;
|
||||
gp.size = 0;
|
||||
@@ -178,8 +159,6 @@ static GroundInstType getInstructionType(const char* inst) {
|
||||
if (strcmp(inst, "lesser") == 0) return LESSER;
|
||||
if (strcmp(inst, "stoi") == 0) return STOI;
|
||||
if (strcmp(inst, "stod") == 0) return STOD;
|
||||
if (strcmp(inst, "ctoi") == 0) return CTOI;
|
||||
if (strcmp(inst, "itoc") == 0) return ITOC;
|
||||
if (strcmp(inst, "tostring") == 0) return TOSTRING;
|
||||
if (strcmp(inst, "fun") == 0) return FUN;
|
||||
if (strcmp(inst, "return") == 0) return RETURN;
|
||||
|
||||
102
src/types.c
102
src/types.c
@@ -90,55 +90,16 @@ GroundValue copyGroundValue(const GroundValue* gv) {
|
||||
}
|
||||
case FUNCTION: newGv.data.fnVal = gv->data.fnVal; break;
|
||||
case STRUCTVAL: {
|
||||
newGv.data.structVal = malloc(sizeof(GroundStruct));
|
||||
if (newGv.data.structVal == NULL) {
|
||||
printf("Couldn't allocate memory for GroundStruct copy\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
newGv.data.structVal->size = gv->data.structVal->size;
|
||||
newGv.data.structVal->fields = malloc(gv->data.structVal->size * sizeof(GroundStructField));
|
||||
if (newGv.data.structVal->fields == NULL && gv->data.structVal->size > 0) {
|
||||
printf("Couldn't allocate memory for GroundStruct fields copy\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < gv->data.structVal->size; i++) {
|
||||
strncpy(newGv.data.structVal->fields[i].id,
|
||||
gv->data.structVal->fields[i].id,
|
||||
sizeof(newGv.data.structVal->fields[i].id) - 1);
|
||||
newGv.data.structVal->fields[i].id[sizeof(newGv.data.structVal->fields[i].id) - 1] = '\0';
|
||||
|
||||
newGv.data.structVal->fields[i].value = copyGroundValue(&gv->data.structVal->fields[i].value);
|
||||
}
|
||||
// do this later lmao
|
||||
// FIXME
|
||||
newGv.data.structVal = gv->data.structVal;
|
||||
break;
|
||||
}
|
||||
case CUSTOM: {
|
||||
newGv.customType = gv->customType;
|
||||
newGv.data.customVal = malloc(sizeof(GroundObject));
|
||||
if (newGv.data.customVal == NULL) {
|
||||
printf("Couldn't allocate memory for GroundObject copy\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
newGv.data.customVal->fields = NULL;
|
||||
|
||||
GroundObjectField *field, *tmp;
|
||||
HASH_ITER(hh, gv->data.customVal->fields, field, tmp) {
|
||||
GroundObjectField* newField = malloc(sizeof(GroundObjectField));
|
||||
if (newField == NULL) {
|
||||
printf("Couldn't allocate memory for GroundObjectField copy\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
strncpy(newField->id, field->id, sizeof(newField->id) - 1);
|
||||
newField->id[sizeof(newField->id) - 1] = '\0';
|
||||
newField->value = copyGroundValue(&field->value);
|
||||
|
||||
HASH_ADD_STR(newGv.data.customVal->fields, id, newField);
|
||||
}
|
||||
case CUSTOM:
|
||||
// also do this later
|
||||
// FIXME
|
||||
newGv.data.customVal = gv->data.customVal;
|
||||
break;
|
||||
}
|
||||
case NONE:
|
||||
default: {
|
||||
|
||||
@@ -188,47 +149,8 @@ void printGroundValue(GroundValue* gv) {
|
||||
printf("<function>");
|
||||
break;
|
||||
}
|
||||
case STRUCTVAL: {
|
||||
printf("<struct fields: { ");
|
||||
for (size_t i = 0; i < gv->data.structVal->size; i++) {
|
||||
if (i != 0) {
|
||||
printf(", ");
|
||||
}
|
||||
printf("%s: ", gv->data.structVal->fields[i].id);
|
||||
if (gv->data.structVal->fields[i].value.type == STRING) {
|
||||
printf("\"");
|
||||
printGroundValue(&gv->data.structVal->fields[i].value);
|
||||
printf("\"");
|
||||
} else {
|
||||
printGroundValue(&gv->data.structVal->fields[i].value);
|
||||
}
|
||||
}
|
||||
printf(" }>");
|
||||
break;
|
||||
}
|
||||
case CUSTOM: {
|
||||
printf("<object fields: { ");
|
||||
for (size_t i = 0; i < gv->customType->size; i++) {
|
||||
if (i != 0) {
|
||||
printf(", ");
|
||||
}
|
||||
printf("%s: ", gv->customType->fields[i].id);
|
||||
GroundObjectField* field = findField(*gv->data.customVal, gv->customType->fields[i].id);
|
||||
if (field == NULL) {
|
||||
printf("<missing>");
|
||||
} else {
|
||||
printGroundValue(&field->value);
|
||||
}
|
||||
}
|
||||
printf(" }>");
|
||||
break;
|
||||
}
|
||||
case ERROR: {
|
||||
printf("<error type: %s, what: %s>", gv->data.errorVal.type, gv->data.errorVal.what);
|
||||
break;
|
||||
}
|
||||
case NONE: {
|
||||
printf("<none>");
|
||||
default: {
|
||||
printf("FIXME");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -452,12 +374,6 @@ void printGroundInstruction(GroundInstruction* gi) {
|
||||
case STOD:
|
||||
printf("stod");
|
||||
break;
|
||||
case CTOI:
|
||||
printf("ctoi");
|
||||
break;
|
||||
case ITOC:
|
||||
printf("itoc");
|
||||
break;
|
||||
case TOSTRING:
|
||||
printf("tostring");
|
||||
break;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "include/uthash.h"
|
||||
|
||||
typedef enum GroundInstType {
|
||||
IF, JUMP, END, INPUT, PRINT, PRINTLN, SET, GETTYPE, EXISTS, SETLIST, SETLISTAT, GETLISTAT, GETLISTSIZE, LISTAPPEND, GETSTRSIZE, GETSTRCHARAT, ADD, SUBTRACT, MULTIPLY, DIVIDE, EQUAL, INEQUAL, NOT, GREATER, LESSER, STOI, STOD, ITOC, CTOI, TOSTRING, FUN, RETURN, ENDFUN, PUSHARG, CALL, STRUCT, ENDSTRUCT, INIT, GETFIELD, SETFIELD, USE, EXTERN, CREATELABEL, PAUSE, DROP, ERRORCMD
|
||||
IF, JUMP, END, INPUT, PRINT, PRINTLN, SET, GETTYPE, EXISTS, SETLIST, SETLISTAT, GETLISTAT, GETLISTSIZE, LISTAPPEND, GETSTRSIZE, GETSTRCHARAT, ADD, SUBTRACT, MULTIPLY, DIVIDE, EQUAL, INEQUAL, NOT, GREATER, LESSER, STOI, STOD, TOSTRING, FUN, RETURN, ENDFUN, PUSHARG, CALL, STRUCT, ENDSTRUCT, INIT, GETFIELD, SETFIELD, USE, EXTERN, CREATELABEL, PAUSE, DROP, ERRORCMD
|
||||
} GroundInstType;
|
||||
|
||||
typedef enum GroundValueType {
|
||||
@@ -63,7 +63,7 @@ typedef struct GroundError {
|
||||
typedef struct GroundValue {
|
||||
GroundValueType type;
|
||||
struct GroundStruct* customType;
|
||||
struct {
|
||||
union {
|
||||
int64_t intVal;
|
||||
double doubleVal;
|
||||
char* stringVal;
|
||||
|
||||
@@ -1,11 +1,3 @@
|
||||
tostring 32 &str
|
||||
stoi "12" &int
|
||||
stod "3.14" &dou
|
||||
itoc 353 &chr
|
||||
ctoi 'a' &it2
|
||||
tostring 32 &int
|
||||
|
||||
println $str
|
||||
println $int
|
||||
println $dou
|
||||
println $chr
|
||||
println $it2
|
||||
|
||||
Reference in New Issue
Block a user