mirror of
https://github.com/Ed94/metadesk.git
synced 2026-08-05 07:08:45 +00:00
Make , and ; behave like \n as unscoped set delimiters.
This commit is contained in:
@@ -43,28 +43,28 @@ Node {
|
|||||||
Tag: @test_tag
|
Tag: @test_tag
|
||||||
Node {
|
Node {
|
||||||
Kind: Label,
|
Kind: Label,
|
||||||
Flags: 00000000000100000000000000000000,
|
Flags: 00000001000100000000000000000000,
|
||||||
Flag Names: Identifier,
|
Flag Names: BeforeComma, Identifier,
|
||||||
String: y,
|
String: y,
|
||||||
Whole String: y,
|
Whole String: y,
|
||||||
Node {
|
Node {
|
||||||
Kind: Label,
|
Kind: Label,
|
||||||
Flags: 00000001000100000000000000000000,
|
Flags: 00000000000100000000000000000000,
|
||||||
Flag Names: BeforeComma, Identifier,
|
Flag Names: Identifier,
|
||||||
String: float,
|
String: float,
|
||||||
Whole String: float,
|
Whole String: float,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Node {
|
Node {
|
||||||
Kind: Label,
|
Kind: Label,
|
||||||
Flags: 00000000000100000000000000000000,
|
Flags: 00000001010100000000000000000000,
|
||||||
Flag Names: Identifier,
|
Flag Names: BeforeComma, AfterComma, Identifier,
|
||||||
String: z,
|
String: z,
|
||||||
Whole String: z,
|
Whole String: z,
|
||||||
Node {
|
Node {
|
||||||
Kind: Label,
|
Kind: Label,
|
||||||
Flags: 00000001000100000000000000000000,
|
Flags: 00000000000100000000000000000000,
|
||||||
Flag Names: BeforeComma, Identifier,
|
Flag Names: Identifier,
|
||||||
String: i32,
|
String: i32,
|
||||||
Whole String: i32,
|
Whole String: i32,
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-5
@@ -1683,20 +1683,29 @@ _MD_ParseSet(MD_ParseCtx *ctx, MD_Node *parent, _MD_ParseSetFlags flags,
|
|||||||
// NOTE(rjf): Separators.
|
// NOTE(rjf): Separators.
|
||||||
{
|
{
|
||||||
MD_b32 result = 0;
|
MD_b32 result = 0;
|
||||||
if(MD_Parse_Require(ctx, MD_S8Lit(","), MD_TokenKind_Symbol))
|
if(terminate_with_separator)
|
||||||
|
{
|
||||||
|
MD_Token next_token = MD_Parse_PeekSkipSome(ctx, 0);
|
||||||
|
if(next_token.kind == MD_TokenKind_Newline ||
|
||||||
|
(next_token.kind == MD_TokenKind_Symbol &&
|
||||||
|
(MD_StringMatch(next_token.string, MD_S8Lit(","), 0) ||
|
||||||
|
MD_StringMatch(next_token.string, MD_S8Lit(";"), 0))))
|
||||||
|
{
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(MD_Parse_Require(ctx, MD_S8Lit(","), MD_TokenKind_Symbol))
|
||||||
{
|
{
|
||||||
result |= 1;
|
|
||||||
child->flags |= MD_NodeFlag_BeforeComma;
|
child->flags |= MD_NodeFlag_BeforeComma;
|
||||||
next_child_flags |= MD_NodeFlag_AfterComma;
|
next_child_flags |= MD_NodeFlag_AfterComma;
|
||||||
}
|
}
|
||||||
else if(MD_Parse_Require(ctx, MD_S8Lit(";"), MD_TokenKind_Symbol))
|
else if(MD_Parse_Require(ctx, MD_S8Lit(";"), MD_TokenKind_Symbol))
|
||||||
{
|
{
|
||||||
result |= 1;
|
|
||||||
child->flags |= MD_NodeFlag_BeforeSemicolon;
|
child->flags |= MD_NodeFlag_BeforeSemicolon;
|
||||||
next_child_flags |= MD_NodeFlag_AfterSemicolon;
|
next_child_flags |= MD_NodeFlag_AfterSemicolon;
|
||||||
}
|
}
|
||||||
result |= (MD_Parse_PeekSkipSome(ctx, 0).kind == MD_TokenKind_Newline);
|
|
||||||
if(result && terminate_with_separator)
|
if(result)
|
||||||
{
|
{
|
||||||
goto end_parse;
|
goto end_parse;
|
||||||
}
|
}
|
||||||
|
|||||||
+64
-41
@@ -11,56 +11,76 @@
|
|||||||
|
|
||||||
//// Arbitrarily deep tree, possibly empty
|
//// Arbitrarily deep tree, possibly empty
|
||||||
// file : [@child set]
|
// file : [@child set]
|
||||||
// set : '{' [@child set] '}' | set [' ' @sibling set]
|
// set : '{' [@child set] '}' | set [separator @sibling set]
|
||||||
|
// separator : ' ' | '\n' | ',' | ';'
|
||||||
|
|
||||||
//// Labeled leaves
|
//// Labeled leaves
|
||||||
// file : [@child set]
|
// file : [@child set]
|
||||||
// set : @fill 'A' | '{' [@child set] '}' | set [' ' @sibling set]
|
// set : @fill 'A' | '{' [@child set] '}' | set [separator @sibling set]
|
||||||
|
// separator : ' ' | '\n' | ',' | ';'
|
||||||
|
|
||||||
//// Labels also on internal nodes ('iset' is an implicitly separated set)
|
//// Labeled internal nodes
|
||||||
// file : [@child set]
|
// file : [@child set]
|
||||||
// set : @fill 'A' [':' @child iset '\n'] | [@fill 'A' ':'] scoped_set | set [' ' @sibling set]
|
// set : @fill 'A' | [@fill 'A' ':'] scoped_set | set [separator @sibling set]
|
||||||
// iset : @fill 'A' [iset_tail]
|
// separator : ' ' | '\n' | ',' | ';'
|
||||||
// iset_tail : ':' @child iset | ' ' @sibling iset | ':' scoped_set | ' ' @sibling scoped_set
|
|
||||||
// scoped_set : '{' [@child set] '}'
|
// scoped_set : '{' [@child set] '}'
|
||||||
|
|
||||||
|
//// Unscoped tests (feels like there should be an easier way to express this)
|
||||||
|
// file : general_set
|
||||||
|
// general_set : { [@child set] | [@child uns_set] }
|
||||||
|
// set : @fill 'A' | set [sep1 @sibling set] | scoped_set | uns_set sep2 @sibling set
|
||||||
|
// uns_set : @fill 'A' [uns_set_tail]
|
||||||
|
// uns_set_tail : ':' @child uns_set | ' ' @sibling uns_set | ':' scoped_set | ' ' @sibling scoped_set
|
||||||
|
// scoped_set : '{' general_set '}'
|
||||||
|
// sep1 : ' ' | '\n' | ',' | ';'
|
||||||
|
// sep2 : '\n'| ',' | ';'
|
||||||
|
|
||||||
//// Tags
|
//// Tags
|
||||||
// file : [@child set]
|
// file : general_set
|
||||||
|
// general_set : { [@child set] | [@child uns_set] }
|
||||||
// set : {[tag_list] untagged_set}
|
// set : {[tag_list] untagged_set}
|
||||||
// iset : {[tag_list] untagged_iset}
|
// uns_set : {[tag_list] untagged_uns_set}
|
||||||
// tag_list : '@' @tag tag ' ' [tag_list]
|
// tag_list : '@' @tag tag ' ' [tag_list]
|
||||||
// tag : @fill 'T'['(' [@child set] ')']
|
// tag : @fill 'T'['(' general_set ')']
|
||||||
// untagged_set : @fill 'A' [':' @child iset '\n'] | [@fill 'A' ':'] scoped_set | set [' ' @sibling set]
|
// untagged_set : @fill 'A' | set [sep1 @sibling set] | scoped_set | uns_set sep2 @sibling set
|
||||||
// untagged_iset : @fill 'A' [iset_tail]
|
// untagged_uns_set: @fill 'A' [uns_set_tail]
|
||||||
// iset_tail : ':' @child iset | ' ' @sibling iset | ':' scoped_set | ' ' @sibling scoped_set
|
// uns_set_tail : ':' @child uns_set | ' ' @sibling uns_set | ':' scoped_set | ' ' @sibling scoped_set
|
||||||
// scoped_set : '{' [@child set] '}'
|
// scoped_set : '{' general_set '}'
|
||||||
|
// sep1 : ' ' | '\n' | ',' | ';'
|
||||||
|
// sep2 : '\n'| ',' | ';'
|
||||||
|
|
||||||
//// Alternative scope markers
|
//// Alternative scope markers
|
||||||
// file : [@child set]
|
// file : general_set
|
||||||
|
// general_set : { [@child set] | [@child uns_set] }
|
||||||
// set : {[tag_list] untagged_set}
|
// set : {[tag_list] untagged_set}
|
||||||
// iset : {[tag_list] untagged_iset}
|
// uns_set : {[tag_list] untagged_uns_set}
|
||||||
// tag_list : '@' @tag tag ' ' [tag_list]
|
// tag_list : '@' @tag tag ' ' [tag_list]
|
||||||
// tag : @fill 'T'['(' [@child set] ')']
|
// tag : @fill 'T'['(' general_set ')']
|
||||||
// untagged_set : @fill 'A' [':' @child iset '\n'] | [@fill 'A' ':'] scoped_set | set [' ' @sibling set]
|
// untagged_set : @fill 'A' | set [sep1 @sibling set] | scoped_set | uns_set sep2 @sibling set
|
||||||
// untagged_iset : @fill 'A' [iset_tail]
|
// untagged_uns_set: @fill 'A' [uns_set_tail]
|
||||||
// iset_tail : ':' @child iset | ' ' @sibling iset | ':' scoped_set | ' ' @sibling scoped_set
|
// uns_set_tail : ':' @child uns_set | ' ' @sibling uns_set | ':' scoped_set | ' ' @sibling scoped_set
|
||||||
// scoped_set : '{' [@child set] '}' | scope_beg [@child set] scope_end
|
// scoped_set : '{' general_set '}' | alt_scope_beg general_set alt_scope_end
|
||||||
// scope_beg : '(' | '['
|
// alt_scope_beg : '(' | '['
|
||||||
// scope_end : ')' | ']'
|
// alt_scope_end : ')' | ']'
|
||||||
|
// sep1 : ' ' | '\n' | ',' | ';'
|
||||||
|
// sep2 : '\n'| ',' | ';'
|
||||||
|
|
||||||
//// Identifiers
|
//// Identifiers
|
||||||
// file : [@child set]
|
// file : general_set
|
||||||
|
// general_set : { [@child set] | [@child uns_set] }
|
||||||
// set : {[tag_list] untagged_set}
|
// set : {[tag_list] untagged_set}
|
||||||
// iset : {[tag_list] untagged_iset}
|
// uns_set : {[tag_list] untagged_uns_set}
|
||||||
// tag_list : '@' @tag tag ' ' [tag_list]
|
// tag_list : '@' @tag tag ' ' [tag_list]
|
||||||
// tag : @fill id['(' [@child set] ')']
|
// tag : @fill id['(' general_set ')']
|
||||||
// untagged_set : @fill 'A' [':' @child iset '\n'] | [@fill 'A' ':'] scoped_set | set [' ' @sibling set]
|
// untagged_set : @fill 'A' | set [sep1 @sibling set] | scoped_set | uns_set sep2 @sibling set
|
||||||
// untagged_iset : @fill 'A' [iset_tail]
|
// untagged_uns_set: @fill 'A' [uns_set_tail]
|
||||||
// iset_tail : ':' @child iset | ' ' @sibling iset | ':' scoped_set | ' ' @sibling scoped_set
|
// uns_set_tail : ':' @child uns_set | ' ' @sibling uns_set | ':' scoped_set | ' ' @sibling scoped_set
|
||||||
// scoped_set : '{' [@child set] '}' | scope_beg [@child set] scope_end
|
// scoped_set : '{' general_set '}' | alt_scope_beg general_set alt_scope_end
|
||||||
// scope_beg : '(' | '['
|
// alt_scope_beg : '(' | '['
|
||||||
// scope_end : ')' | ']'
|
// alt_scope_end : ')' | ']'
|
||||||
// id : alpha [alphanumeric]
|
// sep1 : ' ' | '\n' | ',' | ';'
|
||||||
|
// sep2 : '\n'| ',' | ';'
|
||||||
|
// id : alpha [alphanumeric] | '_' [alphanumeric]
|
||||||
// alphanumeric : alpha [alphanumeric] | digit [alphanumeric] | '_' [alphanumeric]
|
// alphanumeric : alpha [alphanumeric] | digit [alphanumeric] | '_' [alphanumeric]
|
||||||
// alpha : lowercase | uppercase
|
// alpha : lowercase | uppercase
|
||||||
// lowercase : 'a'|'b'|'c'|'d'|'e'|'f'|'g'|'h'|'i'|'j'|'k'|'l'|'m'|'n'|'o'|'p'|'q'|'r'|'s'|'t'|'u'|'v'|'w'|'z'|'y'|'z'
|
// lowercase : 'a'|'b'|'c'|'d'|'e'|'f'|'g'|'h'|'i'|'j'|'k'|'l'|'m'|'n'|'o'|'p'|'q'|'r'|'s'|'t'|'u'|'v'|'w'|'z'|'y'|'z'
|
||||||
@@ -68,17 +88,20 @@
|
|||||||
// digit : '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'
|
// digit : '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'
|
||||||
|
|
||||||
//// General labels
|
//// General labels
|
||||||
file : [@child set]
|
file : general_set
|
||||||
|
general_set : { [@child set] | [@child uns_set] }
|
||||||
set : {[tag_list] untagged_set}
|
set : {[tag_list] untagged_set}
|
||||||
iset : {[tag_list] untagged_iset}
|
uns_set : {[tag_list] untagged_uns_set}
|
||||||
tag_list : '@' @tag tag ' ' [tag_list]
|
tag_list : '@' @tag tag ' ' [tag_list]
|
||||||
tag : @fill id['(' [@child set] ')']
|
tag : @fill id['(' general_set ')']
|
||||||
untagged_set : @fill label [':' @child iset '\n'] | [@fill label ':'] scoped_set | set [' ' @sibling set]
|
untagged_set : @fill label | set [sep1 @sibling set] | scoped_set | uns_set sep2 @sibling set
|
||||||
untagged_iset : @fill label [iset_tail]
|
untagged_uns_set: @fill label [uns_set_tail]
|
||||||
iset_tail : ':' @child iset | ' ' @sibling iset | ':' scoped_set | ' ' @sibling scoped_set
|
uns_set_tail : ':' @child uns_set | ' ' @sibling uns_set | ':' scoped_set | ' ' @sibling scoped_set
|
||||||
scoped_set : '{' [@child set] '}' | scope_beg [@child set] scope_end
|
scoped_set : '{' general_set '}' | alt_scope_beg general_set alt_scope_end
|
||||||
scope_beg : '(' | '['
|
alt_scope_beg : '(' | '['
|
||||||
scope_end : ')' | ']'
|
alt_scope_end : ')' | ']'
|
||||||
|
sep1 : ' ' | '\n' | ',' | ';'
|
||||||
|
sep2 : '\n'| ',' | ';'
|
||||||
id : alpha [alphanumeric] | '_' [alphanumeric]
|
id : alpha [alphanumeric] | '_' [alphanumeric]
|
||||||
alphanumeric : alpha [alphanumeric] | digit [alphanumeric] | '_' [alphanumeric]
|
alphanumeric : alpha [alphanumeric] | digit [alphanumeric] | '_' [alphanumeric]
|
||||||
alpha : lowercase | uppercase
|
alpha : lowercase | uppercase
|
||||||
|
|||||||
Reference in New Issue
Block a user