Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
f7b94ccd
Commit
f7b94ccd
authored
Feb 09, 2001
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Raise exceptions (METALError, TALError) for syntax errors.
parent
120b95ab
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
12 deletions
+10
-12
lib/python/TAL/TALCompiler.py
lib/python/TAL/TALCompiler.py
+10
-12
No files found.
lib/python/TAL/TALCompiler.py
View file @
f7b94ccd
...
...
@@ -252,7 +252,7 @@ class METALCompiler(DOMVisitor):
if
macroName
:
# Save macro definitions
if
self
.
macros
.
has_key
(
macroName
):
print
"Warning: duplicate macro definition for"
,
macroName
raise
METALError
(
"duplicate macro definition: %s"
%
macroName
)
self
.
pushProgram
()
self
.
compileElement
(
node
)
macro
=
self
.
popProgram
()
...
...
@@ -345,15 +345,14 @@ class TALCompiler(METALCompiler):
m
=
re
.
match
(
r"\
s*(?:(glo
bal|local)\
s+)?(%s)
\s+(.*)"
%
NAME_RE
,
part
)
if
not
m
:
print
"Bad syntax in z:define argument:"
,
`part`
raise
TALError
(
"invalid z:define syntax: "
+
`part`
)
scope
,
name
,
expr
=
m
.
group
(
1
,
2
,
3
)
scope
=
scope
or
"local"
cexpr
=
self
.
compileExpression
(
expr
)
if
scope
==
"local"
:
self
.
emit
(
"setLocal"
,
name
,
cexpr
)
else
:
scope
,
name
,
expr
=
m
.
group
(
1
,
2
,
3
)
scope
=
scope
or
"local"
cexpr
=
self
.
compileExpression
(
expr
)
if
scope
==
"local"
:
self
.
emit
(
"setLocal"
,
name
,
cexpr
)
else
:
self
.
emit
(
"setGlobal"
,
name
,
cexpr
)
self
.
emit
(
"setGlobal"
,
name
,
cexpr
)
def
conditionalElement
(
self
,
node
):
condition
=
node
.
getAttributeNS
(
ZOPE_TAL_NS
,
"condition"
)
...
...
@@ -374,7 +373,7 @@ class TALCompiler(METALCompiler):
if
replace
:
n
=
n
+
1
if
repeat
:
n
=
n
+
1
if
n
>
1
:
print
"Please use only one of z:insert, z:replace, z:repeat"
raise
TALError
(
"can't use z:insert, z:replace, z:repeat together"
)
ok
=
0
if
insert
:
ok
=
self
.
doInsert
(
node
,
insert
)
...
...
@@ -417,8 +416,7 @@ class TALCompiler(METALCompiler):
def
doRepeat
(
self
,
node
,
arg
):
m
=
re
.
match
(
"
\
s*(%s)
\
s+(.*)"
%
NAME_RE
,
arg
)
if
not
m
:
print
"Bad syntax in z:repeat:"
,
`arg`
return
0
raise
TALError
(
"invalid z:repeat syntax: "
+
`arg`
)
name
,
expr
=
m
.
group
(
1
,
2
)
cexpr
=
self
.
compileExpression
(
expr
)
self
.
pushProgram
()
...
...
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