Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
9.2.2023: Due to updates GitLab will be unavailable for some minutes between 9:00 and 11:00.
Open sidebar
badw-it
DHParser
Commits
7595cd9c
Commit
7595cd9c
authored
Apr 25, 2017
by
di68kap
Browse files
- additions testbed minilanguage
parent
3b9b93c9
Changes
3
Hide whitespace changes
Inline
Side-by-side
DHParser/ebnf.py
View file @
7595cd9c
...
...
@@ -75,8 +75,6 @@ class EBNFGrammar(GrammarBase):
repetition = "{" expression §"}"
option = "[" expression §"]"
link = regexp | symbol | literal # semantic restriction: symbol must evaluate to a regexp or chain
symbol = /(?!\d)\w+/~ # e.g. expression, factor, parameter_list
literal = /"(?:[^"]|\\")*?"/~ # e.g. "(", '+', 'while'
| /'(?:[^']|\\')*?'/~ # whitespace following literals will be ignored tacitly.
...
...
@@ -99,7 +97,6 @@ class EBNFGrammar(GrammarBase):
regexp
=
RE
(
'~?/(?:[^/]|(?<=
\\\\
)/)*/~?'
)
literal
=
Alternative
(
RE
(
'"(?:[^"]|
\\\\
")*?"'
),
RE
(
"'(?:[^']|
\\\\
')*?'"
))
symbol
=
RE
(
'(?!
\\
d)
\\
w+'
)
link
=
Alternative
(
regexp
,
symbol
,
literal
)
option
=
Sequence
(
Token
(
"["
),
expression
,
Required
(
Token
(
"]"
)))
repetition
=
Sequence
(
Token
(
"{"
),
expression
,
Required
(
Token
(
"}"
)))
oneormore
=
Sequence
(
Token
(
"{"
),
expression
,
Token
(
"}+"
))
...
...
examples/DHParser-Testbed/example.tb
View file @
7595cd9c
...
...
@@ -2,30 +2,51 @@
# language
#######################################################################
match:literal
standard {"literal test double quoted"}
MATCH:literal
{'
literal test
sing
le
s
uoted
'
}
standard {"
literal test
doub
le
q
uoted
"
}
{'literal
multiple lines
with gap'}
{'literal test single suoted'}
whitespace
{'literal with right-attached whitespace' }
{'literal
multiple lines
with gap'}
whitespaced
{'literal with right-attached whitespace' }
fail:literal
FAIL:literal
{ 'literal with left-attached whitespace'}
{quotation marks forgotten}
#######################################################################
match:symbol
"letters" {symbol}
"underscore" {symbol_with_underscore}
""
MATCH:symbol
standard {letters}
{letters_with_underscore}
{numbers_123}
whitespaced {whitespace }
FAIL:symbol
{1_cannot_start_with_number}
{ no_whitespace_on_the_left}
{"with quotation marks it is a literal, not a symbol"}
MATCH:regexp
standard {/\w+/}
{/whitespace/ }
whitespacemarker {~/\w+/~}
right_wsp {/\w+/~}
MATCH:repetition
[{ symbol }]
examples/EBNF/EBNF.ebnf
View file @
7595cd9c
...
...
@@ -29,8 +29,6 @@ oneormore = "{" expression "}+"
repetition = "{" expression §"}"
option = "[" expression §"]"
link = regexp | symbol | literal # semantic restriction: symbol must evaluate to a regexp or chain
symbol = /(?!\d)\w+/~ # e.g. expression, factor, parameter_list
literal = /"(?:[^"]|\\")*?"/~ # e.g. "(", '+', 'while'
| /'(?:[^']|\\')*?'/~ # whitespace following literals will be ignored tacitly.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment