mirror of
https://github.com/CPunch/Cosmo.git
synced 2024-12-04 22:46:31 +00:00
Compare commits
3 Commits
e0455902b0
...
5711ca218e
Author | SHA1 | Date | |
---|---|---|---|
5711ca218e | |||
5cd3049d66 | |||
cd37cfdae5 |
10
README.md
10
README.md
@ -1,7 +1,4 @@
|
|||||||
# Cosmo
|
# Cosmo
|
||||||
[![Check Build](https://github.com/CPunch/Cosmo/actions/workflows/check_build.yaml/badge.svg?branch=main)](https://github.com/CPunch/Cosmo/actions/workflows/check_build.yaml)
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```
|
```
|
||||||
Usage: ./bin/cosmo [-clsr] [args]
|
Usage: ./bin/cosmo [-clsr] [args]
|
||||||
@ -13,6 +10,13 @@ available options are:
|
|||||||
-r start the repl
|
-r start the repl
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://github.com/CPunch/Cosmo/actions/workflows/check_build.yaml"><img src="https://github.com/CPunch/Cosmo/actions/workflows/check_build.yaml/badge.svg?branch=main" alt="Workflow"></a>
|
||||||
|
<a href="https://github.com/CPunch/Cosmo/blob/main/LICENSE.md"><img src="https://img.shields.io/github/license/CPunch/Cosmo" alt="License"></a>
|
||||||
|
<br>
|
||||||
|
<a href="https://asciinema.org/a/629355" target="_blank"><img src="https://asciinema.org/a/629355.svg" /></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
## What is a 'cosmo'?
|
## What is a 'cosmo'?
|
||||||
|
|
||||||
Cosmo is a portable scripting language loosely based off of Lua. Cosmo easily allows the user to extend the language through the use of Proto objects, which describe the behavior of Objects. For example the following is a simple Vector Proto which describes behavior for a Vector-like object.
|
Cosmo is a portable scripting language loosely based off of Lua. Cosmo easily allows the user to extend the language through the use of Proto objects, which describe the behavior of Objects. For example the following is a simple Vector Proto which describes behavior for a Vector-like object.
|
||||||
|
1
main.c
1
main.c
@ -50,6 +50,7 @@ static bool interpret(CState *state, const char *script, const char *mod)
|
|||||||
|
|
||||||
// cosmoV_compileString pushes the result onto the stack (COBJ_ERROR or COBJ_CLOSURE)
|
// cosmoV_compileString pushes the result onto the stack (COBJ_ERROR or COBJ_CLOSURE)
|
||||||
if (cosmoV_compileString(state, script, mod)) {
|
if (cosmoV_compileString(state, script, mod)) {
|
||||||
|
cosmoG_disassemble(cosmoV_readClosure(*cosmoV_getTop(state, 0)));
|
||||||
if (!cosmoV_pcall(state, 0, 1)) {
|
if (!cosmoV_pcall(state, 0, 1)) {
|
||||||
cosmoV_printBacktrace(state, cosmoV_readError(*cosmoV_pop(state)));
|
cosmoV_printBacktrace(state, cosmoV_readError(*cosmoV_pop(state)));
|
||||||
return false;
|
return false;
|
||||||
|
@ -223,3 +223,8 @@ int disasmInstr(CChunk *chunk, int offset, int indent)
|
|||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cosmoG_disassemble(CObjClosure *closure)
|
||||||
|
{
|
||||||
|
disasmChunk(&closure->function->chunk, closure->function->name == NULL ? UNNAMEDCHUNK : closure->function->name->str, 0);
|
||||||
|
}
|
@ -2,10 +2,13 @@
|
|||||||
#define CDEBUG_H
|
#define CDEBUG_H
|
||||||
|
|
||||||
#include "cchunk.h"
|
#include "cchunk.h"
|
||||||
|
#include "cobj.h"
|
||||||
|
|
||||||
COSMO_API void disasmChunk(CChunk *chunk, const char *name, int indent);
|
COSMO_API void disasmChunk(CChunk *chunk, const char *name, int indent);
|
||||||
COSMO_API int disasmInstr(CChunk *chunk, int offset, int indent);
|
COSMO_API int disasmInstr(CChunk *chunk, int offset, int indent);
|
||||||
|
|
||||||
void printIndent(int indent);
|
void printIndent(int indent);
|
||||||
|
|
||||||
|
COSMO_API void cosmoG_disassemble(CObjClosure *closure);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -103,7 +103,6 @@ static int expressionPrecedence(CParseState *pstate, int needed, Precedence prec
|
|||||||
static int expression(CParseState *pstate, int needed, bool forceNeeded);
|
static int expression(CParseState *pstate, int needed, bool forceNeeded);
|
||||||
static void statement(CParseState *pstate);
|
static void statement(CParseState *pstate);
|
||||||
static void parseFunction(CParseState *pstate, FunctionType type);
|
static void parseFunction(CParseState *pstate, FunctionType type);
|
||||||
static void expressionStatement(CParseState *pstate);
|
|
||||||
static ParseRule *getRule(CTokenType type);
|
static ParseRule *getRule(CTokenType type);
|
||||||
static CObjFunction *endCompiler(CParseState *pstate);
|
static CObjFunction *endCompiler(CParseState *pstate);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user