You can use double quote when defining a concept name to protect keyword
This commit is contained in:
@@ -311,6 +311,18 @@ def concept add one to a as
|
||||
|
||||
assert not parser.has_error
|
||||
|
||||
@pytest.mark.parametrize("text", [
|
||||
'def concept "def concept x"',
|
||||
'def concept "def concept x" as x',
|
||||
])
|
||||
def test_i_can_use_double_quotes_to_protect_keywords(self, text):
|
||||
sheerka, context, parser = self.init_parser()
|
||||
res = parser.parse(context, ParserInput(text))
|
||||
concept_defined = res.value.value
|
||||
|
||||
assert res.status
|
||||
assert concept_defined.name.tokens == list(Tokenizer("def concept x", yield_eof=False))
|
||||
|
||||
@pytest.mark.parametrize("text", [
|
||||
"def concept name from bnf as here is my body",
|
||||
"def concept name from def as here is my body",
|
||||
@@ -380,20 +392,6 @@ def concept add one to a as
|
||||
assert context.sheerka.isinstance(res.value, BuiltinConcepts.NOT_FOR_ME)
|
||||
assert isinstance(res.value.body[0], CannotHandleErrorNode)
|
||||
|
||||
# def test_i_can_parse_is_a(self):
|
||||
# text = "the name of my 'concept' isa the name of the set"
|
||||
# sheerka, context, parser = self.init_parser()
|
||||
# res = parser.parse(context, ParserInput(text))
|
||||
# expected = IsaConceptNode([],
|
||||
# concept=NameNode(list(Tokenizer("the name of my 'concept'"))),
|
||||
# set=NameNode(list(Tokenizer("the name of the set"))))
|
||||
#
|
||||
# assert res.status
|
||||
# assert res.who == parser.name
|
||||
# assert res.value.source == text
|
||||
# assert isinstance(res.value, ParserResultConcept)
|
||||
# assert res.value.value == expected
|
||||
|
||||
@pytest.mark.parametrize("text", [
|
||||
"def",
|
||||
"def concept_name"
|
||||
|
||||
Reference in New Issue
Block a user