コード例 #1
0
 def test_string(self):
     self.assertTrue(STRING.load(""" "algo" """).value == "algo")
     self.assertTrue(
         STRING.load(""" "algo y algo" """).value == "algo y algo")
     self.assertTrue(
         STRING.load(""" "algo es \\"algo\\"" """).value ==
         '''algo es \\"algo\\"''')
     self.assertTrue(
         STRING.load(""" "algo es \\"algo\\"" """).unescape() ==
         '''algo es "algo"''')
コード例 #2
0
ファイル: expressions.py プロジェクト: jgoppert/pymodelica
    syntax = delimitedList(Expression.names('expressions'), delim=","),
    )

ExpressionList.ebnf(
    syntax = delimitedList(Expression.names('expressions'), delim=","),
    )

ArraySubscripts.ebnf(
    syntax = Suppress("[") + delimitedList(Subscript.names('subscripts'), delim=",") + Suppress("]"),
    )

Subscript.ebnf(
    syntax = Suppress(":") ^ Expression.name("expression"),
    )

ComponentReference.ebnf(
    syntax = IDENT.name("identifier"),
    )

Comment.ebnf(
    syntax = StringComment.name("comment") + Optional(Annotation.name("annotation")),
    )

StringComment.ebnf(
    syntax = delimitedList(STRING.names('comments'), delim="+"),
    )

Annotation.ebnf(
    syntax = Literal("annotation") + ClassModification.name('modification'),
    )
コード例 #3
0
ファイル: expressions.py プロジェクト: jgoppert/pymodelica
Expression.ebnf(syntax=IDENT.name("identifier"))

NamedArguments.ebnf(syntax=delimitedList(NamedArgument.names('arguments'),
                                         delim=","), )

NamedArgument.ebnf(syntax=IDENT.name('identifier') + Suppress("=") +
                   Expression.name('expression'), )

OutputExpressionList.ebnf(syntax=delimitedList(Expression.names('expressions'),
                                               delim=","), )

ExpressionList.ebnf(syntax=delimitedList(Expression.names('expressions'),
                                         delim=","), )

ArraySubscripts.ebnf(syntax=Suppress("[") +
                     delimitedList(Subscript.names('subscripts'), delim=",") +
                     Suppress("]"), )

Subscript.ebnf(syntax=Suppress(":") ^ Expression.name("expression"), )

ComponentReference.ebnf(syntax=IDENT.name("identifier"), )

Comment.ebnf(syntax=StringComment.name("comment") +
             Optional(Annotation.name("annotation")), )

StringComment.ebnf(syntax=delimitedList(STRING.names('comments'), delim="+"), )

Annotation.ebnf(syntax=Literal("annotation") +
                ClassModification.name('modification'), )
コード例 #4
0
ファイル: tests.py プロジェクト: jgoppert/pymodelica
 def test_string(self):
     self.assertTrue(STRING.load(""" "algo" """).value == "algo")
     self.assertTrue(STRING.load(""" "algo y algo" """).value == "algo y algo")
     self.assertTrue(STRING.load(""" "algo es \\"algo\\"" """).value == '''algo es \\"algo\\"''')
     self.assertTrue(STRING.load(""" "algo es \\"algo\\"" """).unescape() == '''algo es "algo"''')
コード例 #5
0
 def test_string(self):
     self.assertEqual(STRING("algo y algo").dump(), '''"algo y algo"''')