diff --git a/repository/TiddlyWiki/WikiTextGrammar.class.st b/repository/TiddlyWiki/WikiTextGrammar.class.st new file mode 100644 index 0000000..f11b69d --- /dev/null +++ b/repository/TiddlyWiki/WikiTextGrammar.class.st @@ -0,0 +1,42 @@ +Class { + #name : #WikiTextGrammar, + #superclass : #PP2CompositeNode, + #instVars : [ + 'document', + 'link', + 'linkOpen', + 'linkContent', + 'linkClose' + ], + #category : #'TiddlyWiki-Model' +} + +{ #category : #accessing } +WikiTextGrammar >> document [ + ^ link islandInSea star +] + +{ #category : #accessing } +WikiTextGrammar >> link [ + ^ linkOpen, linkContent, linkClose ==> #second +] + +{ #category : #accessing } +WikiTextGrammar >> linkClose [ + ^ ']]' asPParser +] + +{ #category : #accessing } +WikiTextGrammar >> linkContent [ + ^ #any asPParser starLazy flatten +] + +{ #category : #accessing } +WikiTextGrammar >> linkOpen [ + ^ '[[' asPParser +] + +{ #category : #accessing } +WikiTextGrammar >> start [ + ^ document +] diff --git a/repository/TiddlyWiki/WikiTextGrammarTest.class.st b/repository/TiddlyWiki/WikiTextGrammarTest.class.st new file mode 100644 index 0000000..8f77ed0 --- /dev/null +++ b/repository/TiddlyWiki/WikiTextGrammarTest.class.st @@ -0,0 +1,17 @@ +Class { + #name : #WikiTextGrammarTest, + #superclass : #PP2CompositeNodeTest, + #category : #'TiddlyWiki-Model' +} + +{ #category : #accessing } +WikiTextGrammarTest >> parserClass [ + ^ WikiTextGrammar +] + +{ #category : #accessing } +WikiTextGrammarTest >> testLink [ + self + parse: '[[Just testing]]' + rule: #link +]