Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
arpeggio-gm
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
backend
arpeggio-gm
Commits
79b8e8d9
Commit
79b8e8d9
authored
Jan 23, 2011
by
Igor Dejanovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support for adding nodes to predicates and repetitions.
parent
6d7fe26e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
2 deletions
+13
-2
__init__.py
arpeggio/__init__.py
+13
-2
No files found.
arpeggio/__init__.py
View file @
79b8e8d9
...
...
@@ -211,11 +211,16 @@ class Repetition(ParsingExpression):
'''
Base class for all repetition-like parser expressions (?,*,+)
'''
def
__init__
(
self
,
*
elements
):
def
__init__
(
self
,
*
elements
,
**
kwargs
):
super
(
Repetition
,
self
)
.
__init__
(
None
)
if
len
(
elements
)
==
1
:
elements
=
elements
[
0
]
self
.
elements
=
elements
nodes
=
kwargs
.
get
(
'nodes'
,
[])
if
not
hasattr
(
nodes
,
'__iter__'
):
nodes
=
[
nodes
]
self
.
nodes
=
nodes
class
Optional
(
Repetition
):
...
...
@@ -276,10 +281,16 @@ class SyntaxPredicate(ParsingExpression):
Predicates are parser expressions that will do the match but will not consume
any input.
'''
def
__init__
(
self
,
*
elements
):
def
__init__
(
self
,
*
elements
,
**
kwargs
):
if
len
(
elements
)
==
1
:
elements
=
elements
[
0
]
self
.
elements
=
elements
nodes
=
kwargs
.
get
(
'nodes'
,
[])
if
not
hasattr
(
nodes
,
'__iter__'
):
nodes
=
[
nodes
]
self
.
nodes
=
nodes
super
(
SyntaxPredicate
,
self
)
.
__init__
(
None
)
class
And
(
SyntaxPredicate
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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