Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ IfMacros:
- KJ_IF_MAYBE
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^"jay/'
Priority: 1
CaseSensitive: true
- Regex: '^"jary/'
Priority: 2
CaseSensitive: true
Expand Down
10 changes: 10 additions & 0 deletions include/jary/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,14 @@ int sc_strfmt(struct sc_mem *alloc, char **str, const char *fmt, ...);
int sc_reap(struct sc_mem *alloc, void *buf, free_t expire);
void sc_free(struct sc_mem *alloc);

static inline struct sb_mem *sc_linbuf(struct sc_mem *alloc)
{
void *ptr = sc_alloc(alloc, sizeof(struct sb_mem));

if (sc_reap(alloc, ptr, (free_t) sb_free))
return 0;

return (struct sb_mem *) ptr;
}

#endif // JAYVM_MEM_H
8 changes: 4 additions & 4 deletions lib/jay/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,22 @@ if( CMAKE_C_COMPILER_ID MATCHES "^(Clang|GNU)$" )
endif()

target_include_directories( scanner
PUBLIC
PRIVATE
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/lib/jay
)
target_include_directories( parser
PUBLIC
PRIVATE
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/lib/jay
)
target_include_directories( compiler
PUBLIC
PRIVATE
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/lib/jay
)
target_include_directories( exec
PUBLIC
PRIVATE
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/lib/jay
)
Expand Down
1 change: 0 additions & 1 deletion lib/jay/compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1716,7 +1716,6 @@ static inline bool _rule_decl(const struct jy_asts *asts,
// patch jumps to END
for (uint32_t i = 0; i < patchsz; ++i) {
uint32_t ofs = patchofs[i];
// TODO: Handle long jump scenario
short jmp = (short) (*ctx.codesz - ofs + 1);

memcpy(*ctx.codes + ofs, &jmp, sizeof(jmp));
Expand Down
10 changes: 5 additions & 5 deletions lib/jay/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1444,15 +1444,15 @@ static bool _precedence(struct parser *p,
goto PANIC;
}

enum jy_tkn inftype = tkns->types[p->tkn];
enum prec nextprec = tkn_prec(inftype);
enum jy_tkn inftype = tkns->types[p->tkn];
enum prec lbp = tkn_prec(inftype);

while (rbp < nextprec) {
while (rbp < lbp) {
if (_infix(inftype, p, asts, tkns, errs, root))
goto PANIC;

inftype = tkns->types[p->tkn];
nextprec = tkn_prec(inftype);
inftype = tkns->types[p->tkn];
lbp = tkn_prec(inftype);
}

return ended(tkns->types, tkns->size);
Expand Down
Loading