From a3eb7e16a727849c58cbabe3b1b9ef64b6f740f6 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Mon, 26 May 2025 13:02:00 +0200 Subject: restructure PEG for simpler adding SemWord --- syntax/def.peg | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'syntax/def.peg') diff --git a/syntax/def.peg b/syntax/def.peg index 7696a0d..0c99c80 100644 --- a/syntax/def.peg +++ b/syntax/def.peg @@ -28,12 +28,18 @@ StyledWords <- '**' Words '**' LinkedWords <- '[' Words ']' '(' ((Uri _)? LinkTitle / Uri) ')' / '[' Words ']' LinkLabel / LinkLabel -AnnotatedWords <- '[' Words ']' '{' ![{}] PlainWords '}' +AnnotatedWords <- '[' Words ']' '{' KeyWords '}' LinkLabel <- '[' _? ![\[\]] PlainWords _? ']' LinkTitle <- '"' _? !'"' _? PlainWords _? '"' / "'" _? !"'" PlainWords _? "'" / "(" _? ![()] PlainWords _? ")" +KeyWords <- KeyWord (_ KeyWord)* PlainWords <- PRINTABLES (_ PRINTABLES)* +KeyWord <- Identifier / Class / Attribute / '-' +Identifier <- '#' [[:alpha:]] [[:alnum:]]* +Class <- '.' [[:alpha:]] [[:alnum:]]* +Attribute <- [[:alpha:]] [[:alnum:]]* SPACE* = SPACE* + ('"' [[:alnum:]]+ '"' / [[:alnum:]]+) Uri <- '<' ![<>] PRINTABLES? '>' / ![<>] PRINTABLES HardBreak <- SPACE SPACE+ NEWLINE @@ -55,9 +61,7 @@ BlockX <- LinkDefinition / List / Paragraph PrefixDefinition <- '{' CuriePrefix '}' ':' _? SemWord NEWLINE -AnnotatedWordsX <- '[' Words ']' - ('{' (SemWords / ![{}] PlainWords) '}') -SemWords <- SemWord (_ SemWord)* +KeyWordX <- SemWord / Identifier / Class / Attribute / '-' SemWord <- SEMPREFIX '<' ![<>] PRINTABLES '>' / SEMPREFIX Curie SEMPREFIX <- [.=] -- cgit v1.2.3