Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pascal-compiler
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Harbor 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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lior Spach
pascal-compiler
Commits
4952f562
Commit
4952f562
authored
9 years ago
by
Lior Spach
Browse files
Options
Downloads
Patches
Plain Diff
update TabSimb.scala
parent
43a742fb
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/scala/other/TabelaSimb.scala
+14
-3
14 additions, 3 deletions
src/main/scala/other/TabelaSimb.scala
with
14 additions
and
3 deletions
src/main/scala/other/TabelaSimb.scala
+
14
−
3
View file @
4952f562
package
other
import
scala.annotation.tailrec
abstract
class
Entrada
(
val
id
:
String
)
class
Entrada
(
val
id
:
String
)
case
class
Funcao
(
override
val
id
:
String
,
paramInfo
:
List
[
Param
],
desloc
:
Int
,
nvLex
:
Int
,
rotEntrada
:
String
)
extends
Entrada
(
id
)
case
class
Procedimento
(
override
val
id
:
String
,
paramInfo
:
List
[
Param
],
...
...
@@ -26,7 +26,6 @@ object TabelaSimb {
}
def
getLastProc
(
nvLex
:
Int
)
=
{
print
table
.
find
{
case
p
:
Procedimento
=>
if
(
p
.
nvLex
==
nvLex
)
true
else
false
case
f
:
Funcao
=>
if
(
f
.
nvLex
==
nvLex
)
true
else
false
...
...
@@ -34,7 +33,19 @@ object TabelaSimb {
}.
get
}
@annotation
.
tailrec
@tailrec
def
temParamOuVarComMesmoId
(
nome
:
String
,
rest
:
List
[
Entrada
]
=
table
)
:
Boolean
=
{
//No escopo da ultima funcao/proc
val
e
=
getById
(
nome
)
rest
match
{
case
(
p
:
Procedimento
)
::
xs
=>
false
case
(
f
:
Funcao
)
::
xs
=>
false
case
(
v
:
Var
)
::
xs
=>
if
(
v
.
id
==
nome
)
true
else
temParamOuVarComMesmoId
(
nome
,
xs
)
case
(
p
:
Param
)
::
xs
=>
if
(
p
.
id
==
nome
)
true
else
temParamOuVarComMesmoId
(
nome
,
xs
)
case
_
=>
false
}
}
@tailrec
def
numVarsLocais
(
nvLex
:
Int
,
count
:
Int
=
0
,
rest
:
List
[
Entrada
]
=
table
)
:
Int
=
rest
match
{
case
(
v
:
Var
)
::
xs
=>
numVarsLocais
(
nvLex
,
count
+
1
,
xs
)
case
(
p
:
Procedimento
)
::
xs
=>
if
(
p
.
nvLex
>
nvLex
)
numVarsLocais
(
nvLex
,
count
,
xs
)
else
count
...
...
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