Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gcc-cobol
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
COBOLworx
gcc-cobol
Commits
367c99ef
Commit
367c99ef
authored
10 months ago
by
James K. Lowden
Browse files
Options
Downloads
Patches
Plain Diff
introduce name cache to lexer
parent
518e56a5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#1719
passed
10 months ago
Stage: build
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gcc/cobol/scan_ante.h
+23
-2
23 additions, 2 deletions
gcc/cobol/scan_ante.h
with
23 additions
and
2 deletions
gcc/cobol/scan_ante.h
+
23
−
2
View file @
367c99ef
...
...
@@ -410,6 +410,27 @@ static int symbol_function_token( const char name[] ) {
return
e
?
symbol_index
(
e
)
:
0
;
}
static
symbol_elem_t
*
symbol_exists
(
const
char
name
[]
)
{
typedef
std
::
map
<
std
::
string
,
size_t
>
name_cache_t
;
static
std
::
map
<
size_t
,
name_cache_t
>
cachemap
;
cbl_name_t
lname
;
std
::
transform
(
name
,
name
+
strlen
(
name
)
+
1
,
lname
,
tolower
);
auto
&
cache
=
cachemap
[
PROGRAM
];
auto
p
=
cache
.
find
(
lname
);
if
(
p
==
cache
.
end
()
)
{
symbol_elem_t
*
e
=
symbol_field
(
PROGRAM
,
0
,
name
);
if
(
!
e
)
return
NULL
;
cache
[
lname
]
=
symbol_index
(
e
);
return
e
;
}
size_t
isym
=
p
->
second
;
return
symbol_at
(
cache
[
lname
]
=
isym
);
}
static
int
typed_name
(
const
char
name
[]
)
{
if
(
0
==
PROGRAM
)
return
NAME
;
...
...
@@ -421,7 +442,7 @@ typed_name( const char name[] ) {
struct
symbol_elem_t
*
e
=
symbol_special
(
PROGRAM
,
name
);
if
(
e
)
return
cbl_special_name_of
(
e
)
->
token
;
e
=
symbol_
field
(
PROGRAM
,
0
,
name
);
e
=
symbol_
exists
(
name
);
auto
type
=
e
&&
e
->
type
==
SymField
?
cbl_field_of
(
e
)
->
type
:
FldInvalid
;
...
...
@@ -567,7 +588,7 @@ might_be(void) {
assert(yyleng > 0);
for( char *name = yytext + yyleng - 1; name > yytext; name-- ) {
if( isspace(*name) ) {
symbol_elem_t *e = symbol_
field(PROGRAM, 0,
++name);
symbol_elem_t *e = symbol_
exists(
++name);
// TRUE if the input names a field that isn't a level 88 or switch
return e && e->type == SymField &&
cbl_field_of(e)->type != FldSwitch && cbl_field_of(e)->level != 88;
...
...
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