Skip to content

Commit 7fa2bed

Browse files
committed
Rewrote evaluator
* I deleted most of the previous evaluation function once I figured out that state management was unnecessary. It is much more elegant now * Generators and macros can now return failure. This is especially important for macros so that the macro validation and recursive evaluation doesn't occur needlessly * Tokenizer no longer removes escape characters. This is so whatever string the tokenizer reads can be output as a string constant to C/C++ without any issues, and exactly as the user input
1 parent 24bfafa commit 7fa2bed

File tree

6 files changed

+166
-179
lines changed

6 files changed

+166
-179
lines changed

src/Converters.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <stdio.h>
88
#include <string.h>
99

10-
bool writeCharToBuffer(char c, char** at, char* bufferStart, int bufferSize)
10+
static bool writeCharToBuffer(char c, char** at, char* bufferStart, int bufferSize)
1111
{
1212
**at = c;
1313
++(*at);
@@ -25,7 +25,7 @@ bool writeCharToBuffer(char c, char** at, char* bufferStart, int bufferSize)
2525
return true;
2626
}
2727

28-
bool writeStringToBuffer(const char* str, char** at, char* bufferStart, int bufferSize)
28+
static bool writeStringToBuffer(const char* str, char** at, char* bufferStart, int bufferSize)
2929
{
3030
for (const char* c = str; *c != '\0'; ++c)
3131
{

src/Converters.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ struct NameStyleSettings
2929
// WARNING: It is unwise to change this to pascal case because it will destroy C types which
3030
// start with lowercase characters (e.g. "int")
3131
NameStyleMode typeNameMode = NameStyleMode_PascalCaseIfLispy;
32+
// Using a different mode than your C/C++ conventions helps to distinguish Cakelisp functions
33+
// from C/C++ functions, if you want that
3234
NameStyleMode functionNameMode = NameStyleMode_Underscores;
3335
NameStyleMode argumentNameMode = NameStyleMode_CamelCase;
3436
NameStyleMode variableNameMode = NameStyleMode_CamelCase;

src/Main.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,10 @@ int main(int argc, char* argv[])
9595
printf("\nParsing and code generation:\n");
9696

9797
GeneratorOutput generatedOutput;
98-
if (parserGenerateCode(tokens, generatedOutput) != 0)
98+
int numErrors = EvaluateGenerate_Recursive(tokens, /*startTokenIndex=*/0, generatedOutput);
99+
if (numErrors)
99100
return 1;
100-
else
101+
101102
{
102103
NameStyleSettings nameSettings;
103104

0 commit comments

Comments
 (0)