mirror of
https://github.com/Ed94/metadesk.git
synced 2026-06-12 23:51:37 -07:00
woops actually save everything for last commit
This commit is contained in:
@@ -546,39 +546,55 @@ The @code node_count and @code total_size are automatically maintained by the he
|
||||
////////////////////////////////
|
||||
//~ Expression Parser
|
||||
|
||||
// TODO(allen): docs
|
||||
|
||||
@send(ExpressionParser)
|
||||
@doc("This type determines how an operator entered into the expression system is parsed.")
|
||||
@enum MD_ExprOprKind:
|
||||
{
|
||||
Null,
|
||||
@doc("The operator is parsed as a prefix unary operator.")
|
||||
Prefix,
|
||||
@doc("The operator is parsed as a postfix unary operator.")
|
||||
Postfix,
|
||||
@doc("The operator is parsed as a left-to-right binary operator.")
|
||||
Binary,
|
||||
@doc("The operator is parsed as a right-to-left binary operator.")
|
||||
BinaryRightAssociative,
|
||||
COUNT,
|
||||
};
|
||||
|
||||
@send(ExpressionParser)
|
||||
@see(MD_ExprOprKind)
|
||||
@doc("This type caries the primary information regarding an operator in an expression system.")
|
||||
@struct MD_ExprOpr:
|
||||
{
|
||||
@doc("Internal - used in forming chains of operators.")
|
||||
next: *MD_ExprOpr;
|
||||
@doc("User data set on the creation of the operator.")
|
||||
op_id: MD_u32;
|
||||
@doc("Determines what kind of associativity the operator has.")
|
||||
kind: MD_ExprOprKind;
|
||||
@doc("Determines the precedence level of the operator.")
|
||||
precedence: MD_u32;
|
||||
@doc("The string of the operator.")
|
||||
string: MD_String8;
|
||||
@doc("User data set on the creation of the operator.")
|
||||
op_ptr: *void;
|
||||
};
|
||||
|
||||
@send(ExpressionParser)
|
||||
@doc("A simple linked list of MD_ExprOpr nodes. This type is used to gather operators before they are baked down to an optimized operator table.")
|
||||
@struct MD_ExprOprList:
|
||||
{
|
||||
@doc("First node of the chain.")
|
||||
first: *MD_ExprOpr;
|
||||
@doc("Last node of the chain.")
|
||||
last: *MD_ExprOpr;
|
||||
@doc("The number of nodes in the chain.")
|
||||
count: MD_u64;
|
||||
};
|
||||
|
||||
@send(ExpressionParser)
|
||||
@doc("An operator table determines the set of operators that will be understood by the parser. It's exact strucuture is likely to get rearranged whenever it is upgraded to provide faster operator lookups, so it's contents should all be considered 'internal'.")
|
||||
@struct MD_ExprOprTable:
|
||||
{
|
||||
// opaque
|
||||
|
||||
@@ -227,7 +227,7 @@ MD_ExprOprPush(arena, &list, MD_ExprOprKind_##k, p, MD_S8Lit(t), Op##e, 0);
|
||||
C_LIKE_OPS_WITH_SIDE_EFFECTS(PUSH_OP);
|
||||
#undef PUSH_OP
|
||||
|
||||
table = MD_ExprBakeOperatorTableFromList(arena, &list);
|
||||
table = MD_ExprBakeOprTableFromList(arena, &list);
|
||||
}
|
||||
|
||||
// print the verbose parse results
|
||||
|
||||
@@ -206,7 +206,7 @@ int main(int argc, char **argv)
|
||||
MD_ExprOprPush(arena, &list, MD_ExprOprKind_Binary, 2, MD_S8Lit("*"), OpMul, 0);
|
||||
MD_ExprOprPush(arena, &list, MD_ExprOprKind_Binary, 3, MD_S8Lit("&"), OpIllegal, 0);
|
||||
|
||||
table = MD_ExprBakeOperatorTableFromList(arena, &list);
|
||||
table = MD_ExprBakeOprTableFromList(arena, &list);
|
||||
}
|
||||
|
||||
// apply expression parsing to each top level node
|
||||
|
||||
+3
-3
@@ -3746,7 +3746,7 @@ MD_ExprParse_MinPrecedence(MD_Arena *arena, MD_ExprParseCtx *ctx,
|
||||
MD_ExprParse_MinPrecedence(arena, ctx, iter, first, opl, next_min_precedence);
|
||||
if(ctx->errors.max_message_kind == MD_MessageKind_Null)
|
||||
{
|
||||
result = MD_Expr_NewOp(arena, op, node, result, sub_expr);
|
||||
result = MD_Expr_NewOpr(arena, op, node, result, sub_expr);
|
||||
}
|
||||
else{
|
||||
break;
|
||||
@@ -3765,7 +3765,7 @@ MD_ExprParse_MinPrecedence(MD_Arena *arena, MD_ExprParseCtx *ctx,
|
||||
node->flags == ctx->accel.postfix_set_flags[i_op])
|
||||
{
|
||||
*iter = MD_NodeNextWithLimit(*iter, opl);
|
||||
result = MD_Expr_NewOp(arena, op, node, result, 0);
|
||||
result = MD_Expr_NewOpr(arena, op, node, result, 0);
|
||||
found_postfix_setlike_operator = 1;
|
||||
break;
|
||||
}
|
||||
@@ -3776,7 +3776,7 @@ MD_ExprParse_MinPrecedence(MD_Arena *arena, MD_ExprParseCtx *ctx,
|
||||
if(MD_ExprParse_OprConsume(ctx, iter, opl, MD_ExprOprKind_Postfix,
|
||||
min_precedence, &op))
|
||||
{
|
||||
result = MD_Expr_NewOp(arena, op, node, result, 0);
|
||||
result = MD_Expr_NewOpr(arena, op, node, result, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user