Commit 7595cd9c authored by di68kap's avatar di68kap

- additions testbed minilanguage

parent 3b9b93c9
......@@ -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("}+"))
......
......@@ -2,30 +2,51 @@
# language
#######################################################################
match:literal
standard {"literal test double quoted"}
MATCH:literal
{'literal test single suoted'}
standard {"literal test double quoted"}
{'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 }]
......@@ -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.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment