add introductory comments to base64 examples
This commit is contained in:
parent
32dfae0af3
commit
1998ae243a
3 changed files with 39 additions and 0 deletions
|
|
@ -1,3 +1,13 @@
|
|||
// Example parser: Base64, syntax only.
|
||||
//
|
||||
// Demonstrates how to construct a Hammer parser that recognizes valid Base64
|
||||
// sequences.
|
||||
//
|
||||
// Note that no semantic evaluation of the sequence is performed, i.e. the
|
||||
// byte sequence being represented is not returned, or determined. See
|
||||
// base64_sem1.c and base64_sem2.c for examples how to attach appropriate
|
||||
// semantic actions to the grammar.
|
||||
|
||||
#include "../src/hammer.h"
|
||||
|
||||
const HParser* document = NULL;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,17 @@
|
|||
// Example parser: Base64, with fine-grained semantic actions
|
||||
//
|
||||
// Demonstrates how to attach semantic actions to grammar rules and piece by
|
||||
// piece transform the parse tree into the desired semantic representation,
|
||||
// in this case a sequence of 8-bit values.
|
||||
//
|
||||
// Note how the grammar is defined by using the macros H_RULE and H_ARULE.
|
||||
// Those rules using ARULE get an attached action which must be declared (as
|
||||
// (a function of type HAction) with a standard name based on the rule name.
|
||||
//
|
||||
// This variant of the example uses fine-grained semantic actions that
|
||||
// transform the parse tree in small steps in a bottom-up fashion. Compare
|
||||
// base64_sem2.c for an alternative approach using a single top-level action.
|
||||
|
||||
#include "../src/hammer.h"
|
||||
#include "../src/internal.h" // for h_carray functions (XXX ?!)
|
||||
#include <assert.h>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
// Example parser: Base64, with fine-grained semantic actions
|
||||
//
|
||||
// Demonstrates how to attach semantic actions to a grammar and transform the
|
||||
// parse tree into the desired semantic representation, in this case a sequence
|
||||
// of 8-bit values.
|
||||
//
|
||||
// Note how the grammar is defined by using the macros H_RULE and H_ARULE.
|
||||
// Those rules using ARULE get an attached action which must be declared (as
|
||||
// (a function of type HAction) with a standard name based on the rule name.
|
||||
//
|
||||
// This variant of the example uses coarse-grained semantic actions,
|
||||
// transforming the entire parse tree in one big step. Compare base64_sem1.c
|
||||
// for an alternative approach using a fine-grained piece-by-piece
|
||||
// transformation.
|
||||
|
||||
#include "../src/hammer.h"
|
||||
#include "../src/internal.h" // for h_carray functions (XXX ?!)
|
||||
#include <assert.h>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue