Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
5d6de256
Commit
5d6de256
authored
Jul 11, 1997
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New from Jeffrey; small nits.
parent
8a9a4a23
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
Lib/re.py
Lib/re.py
+12
-2
No files found.
Lib/re.py
View file @
5d6de256
...
...
@@ -350,6 +350,7 @@ class SyntaxSpec(Instruction):
self
.
syntax
=
syntax
Instruction
.
__init__
(
self
,
chr
(
20
),
2
)
def
assemble
(
self
,
postition
,
labels
):
# XXX
return
self
.
opcode
+
chr
(
self
.
syntax
)
class
NotSyntaxSpec
(
Instruction
):
...
...
@@ -358,6 +359,7 @@ class NotSyntaxSpec(Instruction):
self
.
syntax
=
syntax
Instruction
.
__init__
(
self
,
chr
(
21
),
2
)
def
assemble
(
self
,
postition
,
labels
):
# XXX
return
self
.
opcode
+
chr
(
self
.
syntax
)
class
Label
(
Instruction
):
...
...
@@ -373,11 +375,15 @@ class OpenParen(Instruction):
def
__init__
(
self
,
register
):
self
.
register
=
register
Instruction
.
__init__
(
self
,
''
,
0
)
def
assemble
(
self
,
position
,
labels
):
raise
error
,
'unmatched open parenthesis'
class
Alternation
(
Instruction
):
name
=
'|'
def
__init__
(
self
):
Instruction
.
__init__
(
self
,
''
,
0
)
def
assemble
(
self
,
position
,
labels
):
raise
error
,
'an alternation was not taken care of'
#
#
...
...
@@ -924,7 +930,9 @@ def compile(pattern, flags=0):
elif
char
==
'*'
:
# Kleene closure
if
len
(
stack
)
==
0
:
raise
error
,
'the Kleene closure needs something to repeat'
raise
error
,
'* needs something to repeat'
if
(
stack
[
-
1
][
0
].
name
==
'('
)
or
(
stack
[
-
1
][
0
].
name
==
'|'
):
raise
error
,
'* needs something to repeat'
registers
=
registers_used
(
stack
[
-
1
])
if
(
index
<
len
(
pattern
))
and
(
pattern
[
index
]
==
'?'
):
# non-greedy matching
...
...
@@ -948,7 +956,9 @@ def compile(pattern, flags=0):
elif
char
==
'+'
:
# positive closure
if
len
(
stack
)
==
0
:
raise
error
,
'the positive closure needs something to repeat'
raise
error
,
'+ needs something to repeat'
if
(
stack
[
-
1
][
0
].
name
==
'('
)
or
(
stack
[
-
1
][
0
].
name
==
'|'
):
raise
error
,
'+ needs something to repeat'
registers
=
registers_used
(
stack
[
-
1
])
if
(
index
<
len
(
pattern
))
and
(
pattern
[
index
]
==
'?'
):
# non-greedy
...
...
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