Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tla2bAST
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
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
general
stups
tla2bAST
Commits
0fc0a1f6
Commit
0fc0a1f6
authored
7 years ago
by
dohan
Browse files
Options
Downloads
Patches
Plain Diff
adapt to new parser
parent
15ecfd4c
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
build.gradle
+16
-7
16 additions, 7 deletions
build.gradle
src/main/java/de/tla2b/output/Renamer.java
+12
-13
12 additions, 13 deletions
src/main/java/de/tla2b/output/Renamer.java
src/main/java/de/tla2bAst/BAstCreator.java
+9
-16
9 additions, 16 deletions
src/main/java/de/tla2bAst/BAstCreator.java
with
37 additions
and
36 deletions
build.gradle
+
16
−
7
View file @
0fc0a1f6
...
...
@@ -28,7 +28,14 @@ configurations.all {
resolutionStrategy
.
cacheChangingModulesFor
0
,
'seconds'
}
def
parser_version
=
'2.7.1-SNAPSHOT'
def
parser_version
if
(
project
.
version
.
endsWith
(
"-SNAPSHOT"
))
{
parser_version
=
'2.9.7-SNAPSHOT'
}
else
{
parser_version
=
'2.9.6'
}
def
tlatools_version
=
'1.0.2'
dependencies
{
...
...
@@ -85,13 +92,15 @@ task createJar(type: Jar, dependsOn: build){
}
task
tla2b
(
dependsOn:
createJar
)
<<
{
task
tla2b
(
dependsOn:
createJar
)
{
doLast
{
copy
{
from
(
'build/libs/'
)
into
(
'.'
)
include
(
'TLA2B.jar'
)
}
}
}
if
(
project
.
hasProperty
(
'ossrhUsername'
)
&&
project
.
hasProperty
(
'ossrhPassword'
))
{
...
...
This diff is collapsed.
Click to expand it.
src/main/java/de/tla2b/output/Renamer.java
+
12
−
13
View file @
0fc0a1f6
package
de.tla2b.output
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Hashtable
;
import
java.util.Set
;
import
de.be4.classicalb.core.parser.util.Utils
;
...
...
@@ -13,17 +13,17 @@ import de.be4.classicalb.core.parser.node.TIdentifierLiteral;
public
class
Renamer
extends
DepthFirstAdapter
{
private
final
java
.
util
.
Hashtable
<
Node
,
String
>
namesTables
;
private
final
HashMap
<
Node
,
String
>
namesTables
;
private
final
Set
<
String
>
globalNames
;
public
Renamer
(
Start
start
)
{
this
.
namesTables
=
new
Hash
table
<
Node
,
String
>();
this
.
globalNames
=
new
HashSet
<
String
>();
this
.
namesTables
=
new
Hash
Map
<
>();
this
.
globalNames
=
new
HashSet
<>();
start
.
apply
(
this
);
}
private
final
static
Set
<
String
>
KEYWORDS
=
new
HashSet
<
String
>();
private
final
static
Set
<
String
>
KEYWORDS
=
new
HashSet
<>();
static
{
KEYWORDS
.
add
(
"seq"
);
KEYWORDS
.
add
(
"left"
);
...
...
@@ -80,7 +80,7 @@ public class Renamer extends DepthFirstAdapter {
@Override
public
void
caseAIdentifierExpression
(
AIdentifierExpression
node
)
{
String
name
=
Utils
.
getIdentifierAsString
(
node
.
getIdentifier
()
);
String
name
=
Utils
.
get
A
IdentifierAsString
(
node
);
String
newName
=
incName
(
name
,
new
HashSet
<
String
>());
namesTables
.
put
(
node
,
newName
);
}
...
...
@@ -93,16 +93,15 @@ public class Renamer extends DepthFirstAdapter {
}
private
Boolean
existingName
(
String
name
)
{
if
(
globalNames
.
contains
(
name
)
||
KEYWORDS
.
contains
(
name
))
{
return
true
;
}
else
return
false
;
return
globalNames
.
contains
(
name
)
||
KEYWORDS
.
contains
(
name
);
}
private
String
incName
(
String
name
,
Set
<
String
>
tempSet
)
{
String
res
=
name
;
for
(
int
i
=
1
;
existingName
(
res
)
||
tempSet
.
contains
(
res
);
i
++)
{
int
i
=
1
;
while
(
existingName
(
res
)
||
tempSet
.
contains
(
res
))
{
res
=
name
+
"_"
+
i
;
i
++;
}
return
res
;
}
...
...
This diff is collapsed.
Click to expand it.
src/main/java/de/tla2bAst/BAstCreator.java
+
9
−
16
View file @
0fc0a1f6
...
...
@@ -34,8 +34,6 @@ import tlc2.value.StringValue;
import
tlc2.value.Value
;
import
tlc2.value.ValueConstants
;
import
de.be4.classicalb.core.parser.Definitions
;
import
de.be4.classicalb.core.parser.exceptions.BException
;
import
de.be4.classicalb.core.parser.exceptions.CheckException
;
import
de.be4.classicalb.core.parser.node.*
;
import
de.hhu.stups.sablecc.patch.PositionedNode
;
import
de.hhu.stups.sablecc.patch.SourcePosition
;
...
...
@@ -262,24 +260,19 @@ public class BAstCreator extends BuiltInOPs
}
if
(
defs
.
size
()
>
0
)
{
if
(
!
defs
.
isEmpty
()
)
{
ADefinitionsMachineClause
defClause
=
new
ADefinitionsMachineClause
();
defClause
.
setDefinitions
(
defs
);
machineClauseList
.
add
(
defClause
);
try
{
for
(
PDefinition
def
:
defs
)
{
if
(
def
instanceof
AExpressionDefinitionDefinition
)
{
bDefinitions
.
addDefinition
((
AExpressionDefinitionDefinition
)
def
,
Definitions
.
Type
.
Expression
);
}
else
if
(
def
instanceof
APredicateDefinitionDefinition
)
{
bDefinitions
.
addDefinition
((
APredicateDefinitionDefinition
)
def
,
Definitions
.
Type
.
Predicate
);
}
else
{
bDefinitions
.
addDefinition
((
ASubstitutionDefinitionDefinition
)
def
,
Definitions
.
Type
.
Substitution
);
}
bDefinitions
.
addDefinition
((
ASubstitutionDefinitionDefinition
)
def
,
Definitions
.
Type
.
Substitution
);
}
}
catch
(
BException
|
CheckException
e
)
{
throw
new
AssertionError
(
e
);
}
}
...
...
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