feat: finally able to overcome the base of the base of this f*cked up mess

This commit is contained in:
mattia
2025-03-01 17:06:56 +01:00
parent eed28168ad
commit 6ee8051004
20 changed files with 518 additions and 2306 deletions

View File

@@ -13,68 +13,72 @@ story: topLevelStatements ;
*/
topLevelStatements:
topLevelStatement+
topLevelStatement (NL+ topLevelStatement)* NL*
;
topLevelStatement:
multiDivert
| contentText
;
knotLevelStatements:
(contentText
| multiDivert
)+
;
stitchLevelStatements:
(contentText
| multiDivert
)+
;
innerBlockLevelStatements:
(contentText
| multiDivert
)+
;
/*
* STATEMENTS
*/
contentText: CONTENT_TEXT_NO_ESCAPE_SIMPLE ;
mixedTextAndLogic:
// TODO: ~ is not allowed as first symbol of this (see InkParser_Content => MixedTextAndLog), let's implement it in the C# side?
// like in innerInlineSequenceObjects, a bit of a chaos to avoid having completely empty entries
contentText? (inlineLogicOrGlueOrTagStart? contentText | inlineLogicOrGlueOrTagStart contentText?)+
// TODO: this is valid only when not parsing a choice, see above for the code where this logic is implemented
multiDivert
// TODO: management of tag ftw O_O
;
inlineLogicOrGlueOrTagStart:
inlineLogic
// TODO: glue, tag start
;
inlineLogic:
INLINE_LOGIC_START
WS?
innerLogic
// TODO: += and -= are disabled here (don't know why, maybe because they're statements?)
WS?
INLINE_LOGIC_END
// TODO: tags ftw
;
innerLogic:
WS?
sequenceTypeAnnotation innerSequenceObjects
// TODO: the rest of InkParser_Logic => InnerLogic
;
//topLevelStatement:
// multiDivert
// | contentText
// ;
//
// knotLevelStatements:
// (contentText
// | multiDivert
// )+
// ;
//
// stitchLevelStatements:
// (contentText
// | multiDivert
// )+
// ;
//
// innerBlockLevelStatements:
// (contentText
// | multiDivert
// )+
// ;
//
///*
// * STATEMENTS
// */
//
//contentText: (CONTENT_TEXT_NO_ESCAPE_NO_IDENT_SIMPLE | IDENTIFIER | WS | SEQUENCE_TYPE_SYMBOL_ANNOTATION | '&' | '$' | '!')+ ;
//
//mixedTextAndLogic:
// // TODO: ~ is not allowed as first symbol of this (see InkParser_Content => MixedTextAndLog), let's implement it in the C# side?
// // like in innerInlineSequenceObjects, a bit of a chaos to avoid having completely empty entries
// contentText? (inlineLogicOrGlueOrTagStart? contentText | inlineLogicOrGlueOrTagStart contentText?)+
// // TODO: this is valid only when not parsing a choice, see above for the code where this logic is implemented
// multiDivert
// // TODO: management of tag ftw O_O
// ;
//
//inlineLogicOrGlueOrTagStart:
// inlineLogic
// // TODO: glue, tag start
// ;
//
//inlineLogic:
// INLINE_LOGIC_START
// WS?
// innerLogic
// // TODO: += and -= are disabled here (don't know why, maybe because they're statements?)
// WS?
// INLINE_LOGIC_END
// // TODO: tags ftw
// ;
//
//innerLogic:
// WS?
// sequenceTypeAnnotation innerSequenceObjects
// // TODO: the rest of InkParser_Logic => InnerLogic
// ;
//
multiDivert:
WS?
multiDivert_withoutWS
@@ -97,21 +101,16 @@ multiDivertArrows_tail:
;
divertIdentifierWithArguments:
WS?
divertIdentifierWithArguments_name
WS?
(
'('
expression (',' WS? expression)*
')'
)?
divertIdentifierWithArguments_arguments?
WS?
;
divertIdentifierWithArguments_name:
WS? identifier WS? ('.' WS? identifier WS? )*
;
divertIdentifierWithArguments_arguments:
'('
expression (',' WS? expression)*
@@ -128,45 +127,45 @@ expression:
IDENTIFIER
;
// all possible symbols or word(s) for sequencing
sequenceTypeAnnotation:
op=SEQUENCE_TYPE_SYMBOL_ANNOTATION
| ONCE
| CYCLE
| SHUFFLE
| STOPPING
| SHUFFLE_ONCE
| SHUFFLE_STOPPING
;
/* a list of sequence objects, either compressed in a single line (e.g.: {a|b|c}) or expanded in multiple lines (e.g.:
{\n- a\n- b\n- c}
*/
innerSequenceObjects:
NL innerMultilineSequenceObjects
| innerInlineSequenceObjects
;
innerMultilineSequenceObjects:
singleMultilineSequenceElement+
;
singleMultilineSequenceElement:
WS?
/* TODO: how to express this? and why is it here? InkParser_Sequences => SingleMultilineSequenceElement
if (ParseString ("->") != null)
return null;
*/
'-'
WS?
(
innerBlockLevelStatements
| MULTILINE_WS
)
;
innerInlineSequenceObjects:
// it's a bit chaotic, in order to allow for empty mixedTextAndLogic, but always require at least one entry
(mixedTextAndLogic ('|' mixedTextAndLogic?)*)
| ('|' mixedTextAndLogic?)+
;
//// all possible symbols or word(s) for sequencing
//sequenceTypeAnnotation:
// op=SEQUENCE_TYPE_SYMBOL_ANNOTATION
// | 'once' WS? ':'
// | 'cycle' WS? ':'
// | 'shuffle' WS? ':'
// | 'stopping' WS? ':'
// | 'shuffle' WS 'once' WS? ':'
// | 'shuffle' WS 'stopping' WS? ':'
// ;
//
///* a list of sequence objects, either compressed in a single line (e.g.: {a|b|c}) or expanded in multiple lines (e.g.:
//{\n- a\n- b\n- c}
//*/
//innerSequenceObjects:
// NL innerMultilineSequenceObjects
// | innerInlineSequenceObjects
// ;
//
//innerMultilineSequenceObjects:
// singleMultilineSequenceElement+
// ;
//
//singleMultilineSequenceElement:
// WS?
// /* TODO: how to express this? and why is it here? InkParser_Sequences => SingleMultilineSequenceElement
// if (ParseString ("->") != null)
// return null;
// */
// '-'
// WS?
// (
// innerBlockLevelStatements
// | MULTILINE_WS
// )
// ;
//
//innerInlineSequenceObjects:
// // it's a bit chaotic, in order to allow for empty mixedTextAndLogic, but always require at least one entry
// (mixedTextAndLogic ('|' mixedTextAndLogic?)*)
// | ('|' mixedTextAndLogic?)+
// ;