mirror of
https://github.com/Ed94/metadesk.git
synced 2026-07-24 00:17:53 +00:00
kill char literal
This commit is contained in:
@@ -331,7 +331,6 @@ enum
|
||||
MD_NodeFlag_Numeric = (1<<10),
|
||||
MD_NodeFlag_Identifier = (1<<11),
|
||||
MD_NodeFlag_StringLiteral = (1<<12),
|
||||
MD_NodeFlag_CharLiteral = (1<<13),
|
||||
};
|
||||
|
||||
#define MD_NodeFlag_AfterFromBefore(f) ((f) << 2)
|
||||
@@ -432,10 +431,6 @@ typedef enum MD_TokenKind
|
||||
// many lines.
|
||||
MD_TokenKind_StringLiteral,
|
||||
|
||||
// A group of arbitrary characters, grouped together by a ' character at the beginning,
|
||||
// and a ' character at the end.
|
||||
MD_TokenKind_CharLiteral,
|
||||
|
||||
// A group of symbolic characters, where symbolic characters means any of the following:
|
||||
// ~!@#$%^&*()-+=[{]}:;<>,./?|\
|
||||
//
|
||||
|
||||
@@ -235,7 +235,6 @@ _MD_NodeParse_ConsumeLiteral(_MD_NodeParseCtx *ctx, MD_Node **out)
|
||||
{
|
||||
MD_b32 result = 0;
|
||||
if(ctx->at->flags & MD_NodeFlag_StringLiteral ||
|
||||
ctx->at->flags & MD_NodeFlag_CharLiteral ||
|
||||
ctx->at->flags & MD_NodeFlag_Numeric)
|
||||
{
|
||||
result = 1;
|
||||
|
||||
+1
-10
@@ -662,7 +662,6 @@ MD_StringListFromNodeFlags(MD_NodeFlags flags)
|
||||
"Numeric",
|
||||
"Identifier",
|
||||
"StringLiteral",
|
||||
"CharLiteral",
|
||||
};
|
||||
|
||||
MD_String8List list = MD_ZERO_STRUCT;
|
||||
@@ -1062,7 +1061,6 @@ MD_NodeFlagsFromTokenKind(MD_TokenKind kind)
|
||||
case MD_TokenKind_Identifier: result = MD_NodeFlag_Identifier; break;
|
||||
case MD_TokenKind_NumericLiteral: result = MD_NodeFlag_Numeric; break;
|
||||
case MD_TokenKind_StringLiteral: result = MD_NodeFlag_StringLiteral; break;
|
||||
case MD_TokenKind_CharLiteral: result = MD_NodeFlag_CharLiteral; break;
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
@@ -1450,12 +1448,6 @@ MD_Parse_LexNext(MD_ParseCtx *ctx)
|
||||
|
||||
// set token kind
|
||||
token.kind = MD_TokenKind_StringLiteral;
|
||||
// TODO(allen): I don't see any place where this actually proves useful.
|
||||
// I think it'd tidy things up to drop it. we already use this as a string
|
||||
// in a lot of usages of metadesk.
|
||||
if (d == '\'' && !is_triplet){
|
||||
token.kind = MD_TokenKind_CharLiteral;
|
||||
}
|
||||
}break;
|
||||
|
||||
// NOTE(allen): Identifiers, Numbers, Operators
|
||||
@@ -1832,13 +1824,12 @@ MD_ParseOneNodeFromCtx(MD_ParseCtx *ctx)
|
||||
else if(MD_Parse_RequireKind(ctx, MD_TokenKind_Identifier, &token) ||
|
||||
MD_Parse_RequireKind(ctx, MD_TokenKind_NumericLiteral, &token) ||
|
||||
MD_Parse_RequireKind(ctx, MD_TokenKind_StringLiteral, &token) ||
|
||||
MD_Parse_RequireKind(ctx, MD_TokenKind_CharLiteral, &token) ||
|
||||
MD_Parse_RequireKind(ctx, MD_TokenKind_Symbol, &token))
|
||||
{
|
||||
result.node = MD_MakeNode(MD_NodeKind_Label, token.string, token.outer_string, token.outer_string.str);
|
||||
result.node->flags |= MD_NodeFlagsFromTokenKind(token.kind);
|
||||
|
||||
if(token.kind == MD_TokenKind_CharLiteral || token.kind == MD_TokenKind_StringLiteral)
|
||||
if(token.kind == MD_TokenKind_StringLiteral)
|
||||
{
|
||||
if(!_MD_StringLiteralIsBalanced(token))
|
||||
{
|
||||
|
||||
+6
-6
@@ -86,7 +86,7 @@ static MD_Node * NewChild(MD_Node *parent)
|
||||
#define SET_DEPTH(depth_map, node, depth) MD_MapOverwrite(depth_map, MD_MapKeyPtr(node), (void *)(depth))
|
||||
static void PrintRule(MD_Map *depth_map, MD_Node *rule)
|
||||
{
|
||||
MD_b32 is_literal_char = rule->flags & MD_NodeFlag_CharLiteral;
|
||||
MD_b32 is_literal_char = rule->flags & MD_NodeFlag_StringLiteral;
|
||||
|
||||
MD_b32 optional = MD_NodeHasTag(rule, MD_S8Lit(OPTIONAL_TAG));
|
||||
|
||||
@@ -221,7 +221,7 @@ static void ExpandRule(MD_Node *rule, MD_String8List *out_strings, MD_Node *cur_
|
||||
}
|
||||
else
|
||||
{
|
||||
if(rule_element->flags & MD_NodeFlag_CharLiteral) // NOTE(mal): Terminal production
|
||||
if(rule_element->flags & MD_NodeFlag_StringLiteral) // NOTE(mal): Terminal production
|
||||
{
|
||||
char c = 0;
|
||||
if(rule_element->string.size == 2 && rule_element->string.str[0] == '\\')
|
||||
@@ -308,7 +308,7 @@ static MD_Node * FindNonTerminalProduction(MD_Node *node, MD_Map *visited)
|
||||
{
|
||||
if(MD_NodeIsNil(node->first_child))
|
||||
{
|
||||
if(node->flags & MD_NodeFlag_CharLiteral)
|
||||
if(node->flags & MD_NodeFlag_StringLiteral)
|
||||
{
|
||||
}
|
||||
else
|
||||
@@ -425,7 +425,7 @@ static void ComputeElementDepth(MD_Map *depth_map, MD_Node *re)
|
||||
}
|
||||
else
|
||||
{
|
||||
if(re->flags & MD_NodeFlag_CharLiteral) // NOTE(mal): Terminal production
|
||||
if(re->flags & MD_NodeFlag_StringLiteral) // NOTE(mal): Terminal production
|
||||
{
|
||||
result = 1;
|
||||
}
|
||||
@@ -561,7 +561,7 @@ int main(int argument_count, char **arguments)
|
||||
else
|
||||
{
|
||||
if(MD_StringMatch(rule_element->string, MD_S8Lit("|"), 0) &&
|
||||
!(rule_element->flags & MD_NodeFlag_CharLiteral))
|
||||
!(rule_element->flags & MD_NodeFlag_StringLiteral))
|
||||
{
|
||||
rule = NewChild(production);
|
||||
}
|
||||
@@ -658,7 +658,7 @@ int main(int argument_count, char **arguments)
|
||||
{
|
||||
MD_u64 depth = 0;
|
||||
MD_Assert(MD_NodeIsNil(rule_element->first_child));
|
||||
if(!(rule_element->flags & MD_NodeFlag_CharLiteral))
|
||||
if(!(rule_element->flags & MD_NodeFlag_StringLiteral))
|
||||
{
|
||||
MD_Node * production = MD_MapLookup(globals.production_table, MD_MapKeyStr(rule_element->string))->val;
|
||||
depth = GET_DEPTH(depth_map, production);
|
||||
|
||||
@@ -287,7 +287,7 @@ int main(void)
|
||||
TestResult(MD_ParseOneNode(MD_S8Lit(""), MD_S8Lit("\"foo\"")).node->flags &
|
||||
MD_NodeFlag_StringLiteral);
|
||||
TestResult(MD_ParseOneNode(MD_S8Lit(""), MD_S8Lit("'foo'")).node->flags &
|
||||
MD_NodeFlag_CharLiteral);
|
||||
MD_NodeFlag_StringLiteral);
|
||||
}
|
||||
|
||||
Test("Expression Evaluation")
|
||||
@@ -395,11 +395,11 @@ int main(void)
|
||||
{
|
||||
TestResult(MD_StringMatch(MD_StringFromNodeKind(MD_NodeKind_Label), MD_S8Lit("Label"), 0));
|
||||
TestResult(MD_StringMatch(MD_StringFromNodeKind(MD_NodeKind_Label), MD_S8Lit("Label"), 0));
|
||||
MD_String8List list = MD_StringListFromNodeFlags(MD_NodeFlag_CharLiteral | MD_NodeFlag_ParenLeft | MD_NodeFlag_BeforeSemicolon);
|
||||
MD_String8List list = MD_StringListFromNodeFlags(MD_NodeFlag_StringLiteral | MD_NodeFlag_ParenLeft | MD_NodeFlag_BeforeSemicolon);
|
||||
MD_b32 match = 1;
|
||||
for(MD_String8Node *node = list.first; node; node = node->next)
|
||||
{
|
||||
if(!MD_StringMatch(node->string, MD_S8Lit("CharLiteral"), 0) &&
|
||||
if(!MD_StringMatch(node->string, MD_S8Lit("StringLiteral"), 0) &&
|
||||
!MD_StringMatch(node->string, MD_S8Lit("ParenLeft"), 0) &&
|
||||
!MD_StringMatch(node->string, MD_S8Lit("BeforeSemicolon"), 0))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user