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
9860782a
Commit
9860782a
authored
5 years ago
by
picomeg
Browse files
Options
Downloads
Patches
Plain Diff
clean up some comments that were just there for my reference during
development
parent
0ea4c749
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/bindings/jni/com/upstandinghackers/hammer/Hammer.java
+2
-2
2 additions, 2 deletions
src/bindings/jni/com/upstandinghackers/hammer/Hammer.java
src/bindings/jni/com_upstandinghackers_hammer_Hammer.c
+4
-127
4 additions, 127 deletions
src/bindings/jni/com_upstandinghackers_hammer_Hammer.c
with
6 additions
and
129 deletions
src/bindings/jni/com/upstandinghackers/hammer/Hammer.java
+
2
−
2
View file @
9860782a
...
...
@@ -77,9 +77,9 @@ public class Hammer
public
static
native
Parser
indirect
();
// public static native Parser bindIndirect(Parser indirect, Parser inner);
public
static
native
Parser
withEndianess
(
byte
endianess
,
Parser
p
);
// public static native Parser bind(Parser p, HContinuation k, void *env);
//would need to work out mappings
// public static native Parser bind(Parser p, HContinuation k, void *env);
public
static
native
Parser
skip
(
int
n
);
public
static
native
Parser
seek
(
int
n
,
int
whence
);
//TODO double check mapping for int whence
public
static
native
Parser
seek
(
int
n
,
int
whence
);
public
static
native
Parser
tell
();
}
This diff is collapsed.
Click to expand it.
src/bindings/jni/com_upstandinghackers_hammer_Hammer.c
+
4
−
127
View file @
9860782a
...
...
@@ -149,13 +149,6 @@ JNIEXPORT jobject JNICALL Java_com_upstandinghackers_hammer_Hammer_middle
RETURNWRAP
(
env
,
h_middle
(
UNWRAP
(
env
,
p
),
UNWRAP
(
env
,
x
),
UNWRAP
(
env
,
q
)));
}
/**
* Given another parser, p, and a function f, returns a parser that
* applies p, then applies f to everything in the AST of p's result.
*
* Result token type: any
*/
//HAMMER_FN_DECL(HParser*, h_action, const HParser* p, const HAction a, void* user_data);
JNIEXPORT
jobject
JNICALL
Java_com_upstandinghackers_hammer_Hammer_in
(
JNIEnv
*
env
,
jclass
class
,
jbyteArray
charset
,
jint
length
)
...
...
@@ -240,31 +233,7 @@ JNIEXPORT jobject JNICALL Java_com_upstandinghackers_hammer_Hammer_choice
RETURNWRAP
(
env
,
result
);
}
/**
* Given a null-terminated list of parsers, match a permutation phrase of these
* parsers, i.e. match all parsers exactly once in any order.
*
* If multiple orders would match, the lexically smallest permutation is used;
* in other words, at any step the remaining available parsers are tried in
* the order in which they appear in the arguments.
*
* As an exception, 'h_optional' parsers (actually those that return a result
* of token type TT_NONE) are detected and the algorithm will try to match them
* with a non-empty result. Specifically, a result of TT_NONE is treated as a
* non-match as long as any other argument matches.
*
* Other parsers that succeed on any input (e.g. h_many), that match the same
* input as others, or that match input which is a prefix of another match can
* lead to unexpected results and should probably not be used as arguments.
*
* The result is a sequence of the same length as the argument list.
* Each parser's result is placed at that parser's index in the arguments.
* The permutation itself (the order in which the arguments were matched) is
* not returned.
*
* Result token type: TT_SEQUENCE
*/
//HAMMER_FN_DECL_VARARGS_ATTR(H_GCC_ATTRIBUTE((sentinel)), HParser*, h_permutation, HParser* p);
JNIEXPORT
jobject
JNICALL
Java_com_upstandinghackers_hammer_Hammer_permutation
(
JNIEnv
*
env
,
jclass
class
,
jobjectArray
permutation
)
{
...
...
@@ -292,6 +261,7 @@ JNIEXPORT jobject JNICALL Java_com_upstandinghackers_hammer_Hammer_permutation
RETURNWRAP
(
env
,
result
);
}
JNIEXPORT
jobject
JNICALL
Java_com_upstandinghackers_hammer_Hammer_butNot
(
JNIEnv
*
env
,
jclass
class
,
jobject
p
,
jobject
q
)
{
...
...
@@ -375,21 +345,6 @@ JNIEXPORT jobject JNICALL Java_com_upstandinghackers_hammer_Hammer_lengthValue
RETURNWRAP
(
env
,
h_length_value
(
UNWRAP
(
env
,
length
),
UNWRAP
(
env
,
value
)));
}
/**
* This parser attaches a predicate function, which returns true or
* false, to a parser. The function is evaluated over the parser's
* result.
*
* The parse only succeeds if the attribute function returns true.
*
* attr_bool will check whether p's result exists and whether p's
* result AST exists; you do not need to check for this in your
* predicate function.
*
* Result token type: p's result type if pred succeeded, NULL otherwise.
*/
//HAMMER_FN_DECL(HParser*, h_attr_bool, const HParser* p, HPredicate pred, void* user_data);
JNIEXPORT
jobject
JNICALL
Java_com_upstandinghackers_hammer_Hammer_and
(
JNIEnv
*
env
,
jclass
class
,
jobject
p
)
...
...
@@ -412,27 +367,6 @@ JNIEXPORT jobject JNICALL Java_com_upstandinghackers_hammer_Hammer_indirect
}
/**
* Set the inner parser of an indirect. See comments on indirect for
* details.
*/
//HAMMER_FN_DECL(void, h_bind_indirect, HParser* indirect, const HParser* inner);
//JNIEXPORT jobject JNICALL Java_com_upstandinghackers_hammer_Hammer_bind_indirect
// (JNIEnv *env, jclass class, jobject indirect, jobject inner)
//{
// RETURNWRAP(env, h_bind_indirect(UNWRAP(env, indirect), UNWRAP(env, inner)));
//}
/**
* This parser runs its argument parser with the given endianness setting.
*
* The value of 'endianness' should be a bit-wise or of the constants
* BYTE_BIG_ENDIAN/BYTE_LITTLE_ENDIAN and BIT_BIG_ENDIAN/BIT_LITTLE_ENDIAN.
*
* Result token type: p's result type.
*/
//HAMMER_FN_DECL(HParser*, h_with_endianness, char endianness, const HParser* p);
JNIEXPORT
jobject
JNICALL
Java_com_upstandinghackers_hammer_Hammer_with_endianness
(
JNIEnv
*
env
,
jclass
class
,
jbyte
endianess
,
jobject
p
)
{
...
...
@@ -440,77 +374,20 @@ JNIEXPORT jobject JNICALL Java_com_upstandinghackers_hammer_Hammer_with_endianne
}
/**
* The 'h_put_value' combinator stashes the result of the parser
* it wraps in a symbol table in the parse state, so that non-
* local actions and predicates can access this value.
*
* Try not to use this combinator if you can avoid it.
*
* Result token type: p's token type if name was not already in
* the symbol table. It is an error, and thus a NULL result (and
* parse failure), to attempt to rename a symbol.
*/
//HAMMER_FN_DECL(HParser*, h_put_value, const HParser *p, const char* name);
/**
* The 'h_get_value' combinator retrieves a named HParseResult that
* was previously stashed in the parse state.
*
* Try not to use this combinator if you can avoid it.
*
* Result token type: whatever the stashed HParseResult is, if
* present. If absent, NULL (and thus parse failure).
*/
//HAMMER_FN_DECL(HParser*, h_get_value, const char* name);
/**
* Monadic bind for HParsers, i.e.:
* Sequencing where later parsers may depend on the result(s) of earlier ones.
*
* Run p and call the result x. Then run k(env,x). Fail if p fails or if
* k(env,x) fails or if k(env,x) is NULL.
*
* Result: the result of k(x,env).
*/
//HAMMER_FN_DECL(HParser*, h_bind, const HParser *p, HContinuation k, void *env);
/**
* This parser skips 'n' bits of input.
*
* Result: None. The HParseResult exists but its AST is NULL.
*/
//HAMMER_FN_DECL(HParser*, h_skip, size_t n);
JNIEXPORT
jobject
JNICALL
Java_com_upstandinghackers_hammer_Hammer_skip
(
JNIEnv
*
env
,
jclass
class
,
jint
n
)
{
RETURNWRAP
(
env
,
h_skip
((
size_t
)
n
));
}
/**
* The HParser equivalent of fseek(), 'h_seek' modifies the parser's input
* position. Note that contrary to 'fseek', offsets are in bits, not bytes.
* The 'whence' argument uses the same values and semantics: SEEK_SET,
* SEEK_CUR, SEEK_END.
*
* Fails if the new input position would be negative or past the end of input.
*
* Result: TT_UINT. The new input position.
*/
//HAMMER_FN_DECL(HParser*, h_seek, ssize_t offset, int whence);
//TODO double check mapping for int
JNIEXPORT
jobject
JNICALL
Java_com_upstandinghackers_hammer_Hammer_seek
(
JNIEnv
*
env
,
jclass
class
,
jint
offset
,
jint
whence
)
{
RETURNWRAP
(
env
,
h_seek
((
ssize_t
)
offset
,
(
int
)
whence
));
}
/**
* Report the current position in bits. Consumes no input.
*
* Result: TT_UINT. The current input position.
*/
//HAMMER_FN_DECL_NOARG(HParser*, h_tell);
JNIEXPORT
jobject
JNICALL
Java_com_upstandinghackers_hammer_Hammer_tell
(
JNIEnv
*
env
,
jclass
class
)
{
...
...
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