#include <easysax.h> #include <stdio.h>
Make callback functions.
void PrintAtt (AttValue av) { printf ("att->%s<-", av.attribute); printf ("\n"); return; } void PrintVal (AttValue av) { printf ("val->%s<-", av.value); printf ("\n"); return; } void PrintA (AttValue av) { PrintAtt (av); PrintVal (av); return; } void PrintText (Text text) { printf ("text->%s<-", text); printf ("\n"); return; } void PrintOpen (Text text) { printf ("open->%s<-", text); printf ("\n"); return; } void PrintClose (Text text) { printf ("close->%s<-", text); printf ("\n"); return; } void PrintD () { printf ("\n"); printf ("*declaration*"); printf ("\n"); return; } void PrintE (Text text) { printf ("error->%s<-", text); printf ("\n"); return; }
int main () {
Make buffer.
CBuffer buffer = InitCBufferFromSTDIN (); if (buffer == NULL) { return 1; }
Make parser.
EasyParser parser = \ InitEasyParser (buffer, &PrintText, &PrintOpen, \ &PrintClose, &PrintA, &PrintD, &PrintE);
Parse.
if (! Parse (parser)) { return 2; }
Destroy objects.
DestroyEasyParser (parser); DestroyCBuffer (buffer); return 0; }