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
Vyrus
hammer
Commits
39c9096f
Commit
39c9096f
authored
9 years ago
by
Meredith L. Patterson
Browse files
Options
Downloads
Patches
Plain Diff
changes from tutorial: add h_literal, make h_make_bytes more practical
parent
33af1ec6
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/glue.c
+2
-2
2 additions, 2 deletions
src/glue.c
src/glue.h
+2
-2
2 additions, 2 deletions
src/glue.h
src/hammer.h
+2
-0
2 additions, 0 deletions
src/hammer.h
with
6 additions
and
4 deletions
src/glue.c
+
2
−
2
View file @
39c9096f
...
@@ -106,11 +106,11 @@ HParsedToken *h_make_seqn(HArena *arena, size_t n)
...
@@ -106,11 +106,11 @@ HParsedToken *h_make_seqn(HArena *arena, size_t n)
return
ret
;
return
ret
;
}
}
HParsedToken
*
h_make_bytes
(
HArena
*
arena
,
size_t
len
)
HParsedToken
*
h_make_bytes
(
HArena
*
arena
,
uint8_t
*
array
,
size_t
len
)
{
{
HParsedToken
*
ret
=
h_make_
(
arena
,
TT_BYTES
);
HParsedToken
*
ret
=
h_make_
(
arena
,
TT_BYTES
);
ret
->
bytes
.
len
=
len
;
ret
->
bytes
.
len
=
len
;
ret
->
bytes
.
token
=
h_arena_malloc
(
arena
,
len
)
;
ret
->
bytes
.
token
=
array
;
return
ret
;
return
ret
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/glue.h
+
2
−
2
View file @
39c9096f
...
@@ -195,7 +195,7 @@ HParsedToken *h_act_ignore(const HParseResult *p, void* user_data);
...
@@ -195,7 +195,7 @@ HParsedToken *h_act_ignore(const HParseResult *p, void* user_data);
HParsedToken
*
h_make
(
HArena
*
arena
,
HTokenType
type
,
void
*
value
);
HParsedToken
*
h_make
(
HArena
*
arena
,
HTokenType
type
,
void
*
value
);
HParsedToken
*
h_make_seq
(
HArena
*
arena
);
// Makes empty sequence.
HParsedToken
*
h_make_seq
(
HArena
*
arena
);
// Makes empty sequence.
HParsedToken
*
h_make_seqn
(
HArena
*
arena
,
size_t
n
);
// Makes empty sequence of expected size n.
HParsedToken
*
h_make_seqn
(
HArena
*
arena
,
size_t
n
);
// Makes empty sequence of expected size n.
HParsedToken
*
h_make_bytes
(
HArena
*
arena
,
size_t
len
);
HParsedToken
*
h_make_bytes
(
HArena
*
arena
,
uint8_t
*
array
,
size_t
len
);
HParsedToken
*
h_make_sint
(
HArena
*
arena
,
int64_t
val
);
HParsedToken
*
h_make_sint
(
HArena
*
arena
,
int64_t
val
);
HParsedToken
*
h_make_uint
(
HArena
*
arena
,
uint64_t
val
);
HParsedToken
*
h_make_uint
(
HArena
*
arena
,
uint64_t
val
);
...
@@ -203,7 +203,7 @@ HParsedToken *h_make_uint(HArena *arena, uint64_t val);
...
@@ -203,7 +203,7 @@ HParsedToken *h_make_uint(HArena *arena, uint64_t val);
#define H_MAKE(TYP, VAL) h_make(p->arena, (HTokenType)TT_ ## TYP, VAL)
#define H_MAKE(TYP, VAL) h_make(p->arena, (HTokenType)TT_ ## TYP, VAL)
#define H_MAKE_SEQ() h_make_seq(p->arena)
#define H_MAKE_SEQ() h_make_seq(p->arena)
#define H_MAKE_SEQN(N) h_make_seqn(p->arena, N)
#define H_MAKE_SEQN(N) h_make_seqn(p->arena, N)
#define H_MAKE_BYTES(LEN) h_make_bytes(p->arena, LEN)
#define H_MAKE_BYTES(
VAL,
LEN) h_make_bytes(p->arena,
VAL,
LEN)
#define H_MAKE_SINT(VAL) h_make_sint(p->arena, VAL)
#define H_MAKE_SINT(VAL) h_make_sint(p->arena, VAL)
#define H_MAKE_UINT(VAL) h_make_uint(p->arena, VAL)
#define H_MAKE_UINT(VAL) h_make_uint(p->arena, VAL)
...
...
This diff is collapsed.
Click to expand it.
src/hammer.h
+
2
−
0
View file @
39c9096f
...
@@ -268,6 +268,8 @@ HAMMER_FN_DECL(HParseResult*, h_parse, const HParser* parser, const uint8_t* inp
...
@@ -268,6 +268,8 @@ HAMMER_FN_DECL(HParseResult*, h_parse, const HParser* parser, const uint8_t* inp
*/
*/
HAMMER_FN_DECL
(
HParser
*
,
h_token
,
const
uint8_t
*
str
,
const
size_t
len
);
HAMMER_FN_DECL
(
HParser
*
,
h_token
,
const
uint8_t
*
str
,
const
size_t
len
);
#define h_literal(s) h_token(s, sizeof(s)-1)
/**
/**
* Given a single character, returns a parser that parses that
* Given a single character, returns a parser that parses that
* character.
* character.
...
...
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