Skip to content

Commit

Permalink
Merge branch 'master' of github.com:dictation-toolbox/dragonfly
Browse files Browse the repository at this point in the history
  • Loading branch information
drmfinlay committed Jun 16, 2021
2 parents 21728b5 + 1593f74 commit 987f6ab
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@
recursive-include dragonfly/examples *.py
include documentation/*
exclude .git*
include dragonfly/parsing/grammar.lark
include dragonfly/engines/backend_kaldi/kag_version.txt
include *.txt *.md *.rst
18 changes: 0 additions & 18 deletions dragonfly/parsing/grammar.lark

This file was deleted.

29 changes: 25 additions & 4 deletions dragonfly/parsing/parse.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
from lark import Lark, Transformer
from ..grammar.elements_basic import Literal, Optional, Sequence, Alternative, Empty
import os

dir_path = os.path.dirname(os.path.realpath(__file__))
from dragonfly.grammar.elements_basic import (Literal, Optional, Sequence,
Alternative, Empty)

spec_parser = Lark.open(os.path.join(dir_path, "grammar.lark"),
grammar_string = r"""
?start: alternative
// ? means that the rule will be inlined iff there is a single child
?alternative: sequence ("|" sequence)*
?sequence: single*
| sequence "{" WORD "}" -> special
?single: WORD+ -> literal
| "<" WORD ">" -> reference
| "[" alternative "]" -> optional
| "(" alternative ")"
// Match anything which is not whitespace or a control character,
// we will let the engine handle invalid words
WORD: /[^\s\[\]<>|(){}]+/
%import common.WS_INLINE
%ignore WS_INLINE
"""

spec_parser = Lark(
grammar_string,
parser="lalr"
)

Expand Down

0 comments on commit 987f6ab

Please sign in to comment.