Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WCCL
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Analysers
WCCL
Commits
006c4af2
Commit
006c4af2
authored
Apr 29, 2011
by
Adam Radziszewski
Browse files
Options
Downloads
Patches
Plain Diff
update converter
parent
0f4ba9e7
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/ruljos2wccl.py
+9
-6
9 additions, 6 deletions
tools/ruljos2wccl.py
with
9 additions
and
6 deletions
tools/ruljos2wccl.py
+
9
−
6
View file @
006c4af2
...
@@ -7,11 +7,14 @@ from StringIO import StringIO
...
@@ -7,11 +7,14 @@ from StringIO import StringIO
descr
=
"""
%prog [options] IN OUT
descr
=
"""
%prog [options] IN OUT
Attempts to convert JOSKIPI rules to WCCL rules.
Attempts to convert JOSKIPI rules to WCCL rules.
NOTE: this is based on very naive heuristics.
NOTE: this is based on very naive heuristics. Dirty regex manipulation is done
instead of real parsing.
Known issues:
1. Will not skip superfluous none in non-empty sets.
2. Complex agreement/hasnum/isbig predicates will not be handled properly.
"""
"""
# TODO agr bits
# TODO isbig -> regex
p_strset
=
re
.
compile
(
u
'
{(
\\
s*
"
[^
"
]*
"
(
\\
s*,
\\
s*
"
[^
"
]*
"
)*
\\
s*)}
'
,
re
.
U
)
p_strset
=
re
.
compile
(
u
'
{(
\\
s*
"
[^
"
]*
"
(
\\
s*,
\\
s*
"
[^
"
]*
"
)*
\\
s*)}
'
,
re
.
U
)
p_negposref
=
re
.
compile
(
u
'
\$\-([0-9]+)([A-Z][A-Za-z0-9]*)
'
)
p_negposref
=
re
.
compile
(
u
'
\$\-([0-9]+)([A-Z][A-Za-z0-9]*)
'
)
...
@@ -58,11 +61,11 @@ class Rule:
...
@@ -58,11 +61,11 @@ class Rule:
self
.
act
=
jos2ccl
(
act
.
strip
())
self
.
act
=
jos2ccl
(
act
.
strip
())
self
.
name
=
name
.
strip
()
self
.
name
=
name
.
strip
()
def
write
(
self
,
out
,
comma
=
False
):
def
write
(
self
,
out
,
sep
=
False
):
out
.
write
(
'
rule(
"
%s
"
,
\n
'
%
self
.
name
)
out
.
write
(
'
rule(
"
%s
"
,
\n
'
%
self
.
name
)
out
.
write
(
'
%s,
\n
'
%
self
.
cond
)
out
.
write
(
'
%s,
\n
'
%
self
.
cond
)
out
.
write
(
'
%s
\n
'
%
self
.
act
)
out
.
write
(
'
%s
\n
'
%
self
.
act
)
out
.
write
(
'
)%s
\n
'
%
(
'
,
'
if
comma
else
''
))
out
.
write
(
'
)%s
\n
'
%
(
'
;
'
if
sep
else
''
))
def
rule_texts
(
infile
):
def
rule_texts
(
infile
):
buf
=
StringIO
()
buf
=
StringIO
()
...
@@ -97,7 +100,7 @@ def go():
...
@@ -97,7 +100,7 @@ def go():
w
=
IndentWriter
(
outf
)
w
=
IndentWriter
(
outf
)
indent
=
0
indent
=
0
w
.
write
(
'
rules(
\n
'
)
w
.
write
(
'
tag_
rules(
\n
'
)
# quick and dirty: to get all but last
# quick and dirty: to get all but last
allrules
=
[
r
for
r
in
rules
(
inf
)]
allrules
=
[
r
for
r
in
rules
(
inf
)]
for
rule
in
allrules
[:
-
1
]:
for
rule
in
allrules
[:
-
1
]:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment