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
Denley Lam
hammer
Commits
8a5c4b6b
Commit
8a5c4b6b
authored
12 years ago
by
Meredith L. Patterson
Browse files
Options
Downloads
Patches
Plain Diff
beginnings of translating parser combinators to regex vm instructions
parent
f5245eaa
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/parsers/optional.c
+9
-0
9 additions, 0 deletions
src/parsers/optional.c
src/parsers/sequence.c
+10
-0
10 additions, 0 deletions
src/parsers/sequence.c
with
19 additions
and
0 deletions
src/parsers/optional.c
+
9
−
0
View file @
8a5c4b6b
...
...
@@ -21,10 +21,19 @@ static bool opt_isValidCF(void *env) {
return
p
->
vtable
->
isValidCF
(
p
->
env
);
}
static
bool
opt_ctrvm
(
struct
HRVMProg_
*
prog
,
void
*
env
)
{
uint16_t
insn
=
h_rvm_insert_insn
(
prog
,
RVM_FORK
,
0
);
if
(
!
h_compile_regex
(
prog
,
(
HParser
*
)
env
->
env
))
return
false
;
h_rvm_patch_arg
(
prog
,
insn
,
h_rvm_get_ip
(
prog
));
return
true
;
}
static
const
HParserVtable
optional_vt
=
{
.
parse
=
parse_optional
,
.
isValidRegular
=
opt_isValidRegular
,
.
isValidCF
=
opt_isValidCF
,
.
compile_to_rvm
=
opt_ctvrm
,
};
const
HParser
*
h_optional
(
const
HParser
*
p
)
{
...
...
This diff is collapsed.
Click to expand it.
src/parsers/sequence.c
+
10
−
0
View file @
8a5c4b6b
...
...
@@ -42,10 +42,20 @@ static bool sequence_isValidCF(void *env) {
return
true
;
}
static
bool
sequence_ctrvm
(
struct
HRVMProg_
*
prog
,
void
*
env
)
{
HSequence
*
s
=
(
HSequence
*
)
env
;
for
(
size_t
i
=
0
;
i
<
s
->
len
;
++
i
)
{
if
(
!
s
->
p_array
[
i
]
->
vtable
->
compile_to_rvm
(
prog
,
s
->
p_array
[
i
]
->
env
))
return
false
;
}
return
true
;
}
static
const
HParserVtable
sequence_vt
=
{
.
parse
=
parse_sequence
,
.
isValidRegular
=
sequence_isValidRegular
,
.
isValidCF
=
sequence_isValidCF
,
.
compile_to_rvm
=
sequence_ctrvm
,
};
const
HParser
*
h_sequence
(
const
HParser
*
p
,
...)
{
...
...
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