Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hammer
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
Letitia Li
hammer
Commits
6a2ee4f6
Commit
6a2ee4f6
authored
5 years ago
by
Sven M. Hallberg
Browse files
Options
Downloads
Patches
Plain Diff
add pprint argument to h_allocate_token_new()
also allow NULL argument for unamb_sub to mean default
parent
a0d225f5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/hammer.h
+2
-1
2 additions, 1 deletion
src/hammer.h
src/registry.c
+5
-4
5 additions, 4 deletions
src/registry.c
with
7 additions
and
5 deletions
src/hammer.h
+
2
−
1
View file @
6a2ee4f6
...
@@ -795,7 +795,8 @@ HTokenType h_allocate_token_type(const char* name);
...
@@ -795,7 +795,8 @@ HTokenType h_allocate_token_type(const char* name);
/// Allocate a new token type with an unambiguous print function.
/// Allocate a new token type with an unambiguous print function.
HTokenType
h_allocate_token_new
(
HTokenType
h_allocate_token_new
(
const
char
*
name
,
const
char
*
name
,
void
(
*
unamb_sub
)(
const
HParsedToken
*
tok
,
struct
result_buf
*
buf
));
void
(
*
unamb_sub
)(
const
HParsedToken
*
tok
,
struct
result_buf
*
buf
),
void
(
*
pprint
)(
FILE
*
stream
,
const
HParsedToken
*
tok
,
int
indent
,
int
delta
));
/// Get the token type associated with name. Returns -1 if name is unkown
/// Get the token type associated with name. Returns -1 if name is unkown
HTokenType
h_get_token_type_number
(
const
char
*
name
);
HTokenType
h_get_token_type_number
(
const
char
*
name
);
...
...
This diff is collapsed.
Click to expand it.
src/registry.c
+
5
−
4
View file @
6a2ee4f6
...
@@ -54,13 +54,14 @@ static void default_unamb_sub(const HParsedToken* tok,
...
@@ -54,13 +54,14 @@ static void default_unamb_sub(const HParsedToken* tok,
HTokenType
h_allocate_token_new
(
HTokenType
h_allocate_token_new
(
const
char
*
name
,
const
char
*
name
,
void
(
*
unamb_sub
)(
const
HParsedToken
*
tok
,
struct
result_buf
*
buf
))
{
void
(
*
unamb_sub
)(
const
HParsedToken
*
tok
,
struct
result_buf
*
buf
),
void
(
*
pprint
)(
FILE
*
stream
,
const
HParsedToken
*
tok
,
int
indent
,
int
delta
))
{
HTTEntry
*
new_entry
=
h_alloc
(
&
system_allocator
,
sizeof
(
*
new_entry
));
HTTEntry
*
new_entry
=
h_alloc
(
&
system_allocator
,
sizeof
(
*
new_entry
));
assert
(
new_entry
!=
NULL
);
assert
(
new_entry
!=
NULL
);
new_entry
->
name
=
name
;
new_entry
->
name
=
name
;
new_entry
->
value
=
0
;
new_entry
->
value
=
0
;
new_entry
->
unamb_sub
=
unamb_sub
;
new_entry
->
unamb_sub
=
unamb_sub
?
unamb_sub
:
default_unamb_sub
;
new_entry
->
pprint
=
NULL
;
new_entry
->
pprint
=
pprint
;
HTTEntry
*
probe
=
*
(
HTTEntry
**
)
tsearch
(
new_entry
,
&
tt_registry
,
compare_entries
);
HTTEntry
*
probe
=
*
(
HTTEntry
**
)
tsearch
(
new_entry
,
&
tt_registry
,
compare_entries
);
if
(
probe
->
value
!=
0
)
{
if
(
probe
->
value
!=
0
)
{
// Token type already exists...
// Token type already exists...
...
@@ -87,7 +88,7 @@ HTokenType h_allocate_token_new(
...
@@ -87,7 +88,7 @@ HTokenType h_allocate_token_new(
}
}
}
}
HTokenType
h_allocate_token_type
(
const
char
*
name
)
{
HTokenType
h_allocate_token_type
(
const
char
*
name
)
{
return
h_allocate_token_new
(
name
,
default_unamb_sub
);
return
h_allocate_token_new
(
name
,
NULL
,
NULL
);
}
}
HTokenType
h_get_token_type_number
(
const
char
*
name
)
{
HTokenType
h_get_token_type_number
(
const
char
*
name
)
{
HTTEntry
e
;
HTTEntry
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