blob: f7d6c99701dcf5fe894e07bc666cd9d2b39e5e7f [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
%token line "\-\-\-\- (\-*)";
%token tabletitleitem "\|\|";
%token tablecolumnitem "\|";
%token titleitem "!!!";
%token subtitleitem "!!";
%token subsubtitleitem "!";
%token emitem "''";
%token codeopenitem "\{\{";
%token codecloseitem "\}\}";
%token strongitem "__";
%token source "\{\{\{ (\}{0,2}[^\}])* \}\}\}";
%token anchor "\[( [^\[\|\]]* \| )? # [^\[\|\]]* \]";
%token link "\[( [^\[\|\]]* \| )? [^\[\|\]]* \]";
%token text "([^\ \t\n\r\[\{\}\|\*\\\-_!#'] | _[^_\n\r] | \{[^\{\n\r] | \}[^\}\n\r] | '[^'\n\r]
| \[\[ | \\[^\\\n\r] | \-{1,3}[^\-\n\r]?)
([^ \n\r\[\{\}\|\\\-_'] | _[^_\n\r] | \{[^\{\n\r] | \}[^\}\n\r] | '[^'\n\r]
| \[\[ | \\[^\\\n\r] | \-{1,3}[^\-\n\r]? | \|[^\|\ \t])*";
%right softbreak "\r(\n?) | \n";
%right break "\\\\";
%right hardbreak "(\r(\n?) | \n) (\r(\n?) | \n)+";
%token bulleted1item "\*";
%token bulleted2item "\*\*";
%token bulleted3item "\*\*\*";
%token numbered1item "#";
%token numbered2item "##";
%token numbered3item "###";
%ignore "[\ \t]+";
%start document;
%%
document
: document section
| section
| paragraphs
;
section
: title paragraphs
| title hardbreak paragraphs
;
title
: titleitem textsequence
;
paragraphs
: paragraphs paragraph hardbreak
| paragraphs paragraph
| paragraph hardbreak
| paragraph
| paragraphs subsection hardbreak
| paragraphs subsection
| subsection hardbreak
| subsection
;
subsection
: subtitle subparagraphs
| subtitle hardbreak subparagraphs
;
subtitle
: subtitleitem textsequence
;
subparagraphs
: subparagraphs paragraph hardbreak
| subparagraphs paragraph
| paragraph hardbreak
| paragraph
| subparagraphs subsubsection hardbreak
| subparagraphs subsubsection
| subsubsection hardbreak
| subsubsection
;
subsubsection
: subsubtitle subsubparagraphs
| subsubtitle hardbreak subsubparagraphs
;
subsubtitle
: subsubtitleitem textsequence
;
subsubparagraphs
: subsubparagraphs paragraph hardbreak
| subsubparagraphs paragraph
| paragraph hardbreak
| paragraph
;
paragraph
: bulletedlist1
| numberedlist1
| textsequence
| line
| source %prec softbreak
| source softbreak
| table
;
bulletedlist1
: bulletedlist1 bulletedlistitem1
| bulletedlistitem1
| bulletedlist1 bulletedlist2
| bulletedlist2
;
bulletedlistitem1
: bulleted1item textsequence
;
bulletedlist2
: bulletedlist2 bulletedlistitem2
| bulletedlistitem2
| bulletedlist2 bulletedlist3
| bulletedlist3
;
bulletedlistitem2
: bulleted2item textsequence
;
bulletedlist3
: bulletedlist3 bulletedlistitem3
| bulletedlistitem3
;
bulletedlistitem3
: bulleted3item textsequence
;
numberedlist1
: numberedlist1 numberedlistitem1
| numberedlistitem1
| numberedlist1 numberedlist2
| numberedlist2
;
numberedlistitem1
: numbered1item textsequence
;
numberedlist2
: numberedlist2 numberedlistitem2
| numberedlistitem2
| numberedlist2 numberedlist3
| numberedlist3
;
numberedlistitem2
: numbered2item textsequence
;
numberedlist3
: numberedlist3 numberedlistitem3
| numberedlistitem3
;
numberedlistitem3
: numbered3item textsequence
;
table
: tablehead softbreak tablerows
| tablehead softbreak tablerows softbreak
| tablerows
| tablerows softbreak
;
tablehead
: tablehead tabletitle
| tabletitle
;
tabletitle
: tabletitleitem textblock
;
tablerows
: tablerows softbreak tablecolumns
| tablecolumns
;
tablecolumns
: tablecolumns tablecolumn
| tablecolumn
;
tablecolumn
: tablecolumnitem textblock
;
textsequence
: textsequence textblock softbreak
| textsequence textblock
| textblock softbreak
| textblock
| textsequence textblock break
| textblock break
;
textblock
: link
| anchor
| strongblock
| emblock
| text
| codeblock
;
emblock
: emitem text emitem
;
strongblock
: strongitem text strongitem
;
codeblock
: codeopenitem text codecloseitem
;