Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
SmallWiki Grammer
Last updated at 12:42 pm UTC on 17 January 2006
SmallWiki Homepage

Scanner and parser are heavily tested using SUnit-Tests and the method coverage tool to make sure that every production rule is hit. To see the code, download the latest version of SmallWiki from Cincom Public StORE.

Scanner

<newline>			: \r? \n | \r ;
<blankLine>			: <newline> <newline> ;

<horizontalRule>		: \_[\ \t]* ;
<header>			: \!+ ;
<list>				: [\#\-]+ ;
<table>				: \| ;
<preformatted>			: \= ;

<alias>				: \> ;
<linkText>			: [^\*\>\r\n]*;
<link>				: \* (<linkText> <alias>)? <linkText> \* ;
<nonLinkStart>			: \*\* | \\ [\[\*\=\!\#\-\|] ;

<codeStart>			: \[ ;
<text>				: [^\r\n\|\\[\!\#\-\=\\]+ ;
<any> 				: . ;

Parser

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

Document
	: DocumentItems ;

DocumentItems 
	:
	| DocumentItem
	| DocumentItems <newline> DocumentItem
	| DocumentItems BlankLine DocumentItem
	| DocumentItems <newline> 
	| DocumentItems BlankLine ;

BlankLine 
	: <blankLine> ;

DocumentItem 
	: HorizontalRule
	| Header
	| List 
	| Preformatted 
	| Table
	| Paragraph ;

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

HorizontalRule 
	: <horizontalRule> ;

Header 
	: <header> 'header' ParagraphItems 'items' ;

List 
	: <list> 'type' ParagraphItems 'items' ;

Preformatted
	: <preformatted> Line 'line' ;

Table
	: TableRow 'row' ;

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

TableRow 
	: TableCells 'cells' ;
TableCells 
	: <table> TableParagraphItems 'paragraph'
	| TableCells 'cells' <table> TableParagraphItems 'paragraph' ;
TableParagraphItems 
	: 
	| TableParagraphItems 'items' Text 'text' 
	| TableParagraphItems 'items' Link 'link' 
	| TableParagraphItems 'items' Code 'code'
	| TableParagraphItems 'items' InternalTableParagraphText 'text' ;
InternalTableParagraphText
	: <horizontalRule> 
	| <header> 
	| <list> 
	| <nonLinkStart> 'text'
	| <preformatted>
	| <any>  ;

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

Paragraph 
	: ParagraphStart 'firstItem' ParagraphItems 'items' ;
ParagraphStart 
	: Text 
	| <nonLinkStart> 'string' 
	| Code 
	| Link
	| <any> 'char'  ;
ParagraphItems
	: 
	| ParagraphItems 'items' Text 'text' 
	| ParagraphItems 'items' Link 'link' 
	| ParagraphItems 'items' Code 'code' 
	| ParagraphItems 'items' InternalTableParagraphText 'text' 
	| ParagraphItems 'items' <table> 'text' ;

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

Link
	: <link> 'link' ;

Line
	: { '' } 
	| Line 'line' InternalTableParagraphText 'text' 
	| Line 'line' <table> 'text' 
	| Line 'line' <text> 'text'  
	| Line 'line' <link> 'link' 
	| Line 'line' <codeStart> 'bracket' ;

Text
	: <text> 'text' ;

Code
	: <codeStart> 'token' ;