simplified grammar, start in .lark file

This commit is contained in:
Guilhem Fauré 2023-04-26 11:27:05 +02:00
parent 236e9e39d4
commit d7247e805a
2 changed files with 13 additions and 18 deletions

View File

@ -2,7 +2,7 @@ from os import path
from lark import Lark from lark import Lark
spipParser = Lark(open(path.dirname(__file__) + "/spip.lark"), start="section") spipParser = Lark(open(path.dirname(__file__) + "/spip.lark"))
# Test # Test

View File

@ -1,27 +1,22 @@
section: list start: unordered_list
| table | ordered_list
| SEPARATOR | table
| N+ | SEPARATOR
| heading | paragraph | _N+
| heading
| paragraph
list: unordered_list unordered_list: ( _N "-*" list_element )+
| unordered_sublist ordered_list: ( _N "-#" list_element )+
| ordered_list
| ordered_sublist
unordered_list: ( N "-*" list_element )+
unordered_sublist: ( N "-**" list_element )+
ordered_list: ( N "-#" list_element )+
ordered_sublist: ( N "-##" list_element )+
list_element: text list_element: text
table: ( N row )+ table: ( _N row )+
row: ( "|" cell )+ "|" row: ( "|" cell )+ "|"
cell: text cell: text
SEPARATOR: N /-{4,}/ SEPARATOR: _N /-{4,}/
N: /\r/? /\n/ _N: /\r/? /\n/
heading: "{{{" text "}}}" heading: "{{{" text "}}}"