mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-10 21:58:48 +01:00
docs; fix example formatting
This commit is contained in:
@ -3,25 +3,34 @@
|
||||
#include <stdio.h>
|
||||
#include "wren.h"
|
||||
|
||||
static void writeFn(WrenVM* vm, const char* text) {
|
||||
static void writeFn(WrenVM* vm, const char* text)
|
||||
{
|
||||
printf("%s", text);
|
||||
}
|
||||
|
||||
void errorFn(WrenVM* vm, WrenErrorType errorType, const char* module, const int line, const char* msg) {
|
||||
switch (errorType) {
|
||||
case WREN_ERROR_COMPILE: {
|
||||
void errorFn(WrenVM* vm, WrenErrorType errorType,
|
||||
const char* module, const int line,
|
||||
const char* msg)
|
||||
{
|
||||
switch (errorType)
|
||||
{
|
||||
case WREN_ERROR_COMPILE:
|
||||
{
|
||||
printf("[%s line %d] [Error] %s\n", module, line, msg);
|
||||
} break;
|
||||
case WREN_ERROR_STACK_TRACE: {
|
||||
case WREN_ERROR_STACK_TRACE:
|
||||
{
|
||||
printf("[%s line %d] in %s\n", module, line, msg);
|
||||
} break;
|
||||
case WREN_ERROR_RUNTIME: {
|
||||
case WREN_ERROR_RUNTIME:
|
||||
{
|
||||
printf("[Runtime Error] %s\n", msg);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
|
||||
WrenConfiguration config;
|
||||
wrenInitConfiguration(&config);
|
||||
@ -34,10 +43,14 @@ int main() {
|
||||
|
||||
WrenInterpretResult result = wrenInterpret(vm, module, script);
|
||||
|
||||
switch (result) {
|
||||
case WREN_RESULT_COMPILE_ERROR: { printf("Compile Error!\n"); } break;
|
||||
case WREN_RESULT_RUNTIME_ERROR: { printf("Runtime Error!\n"); } break;
|
||||
case WREN_RESULT_SUCCESS: { printf("Success!\n"); } break;
|
||||
switch (result)
|
||||
{
|
||||
case WREN_RESULT_COMPILE_ERROR:
|
||||
{ printf("Compile Error!\n"); } break;
|
||||
case WREN_RESULT_RUNTIME_ERROR:
|
||||
{ printf("Runtime Error!\n"); } break;
|
||||
case WREN_RESULT_SUCCESS:
|
||||
{ printf("Success!\n"); } break;
|
||||
}
|
||||
|
||||
wrenFreeVM(vm);
|
||||
|
||||
Reference in New Issue
Block a user