Declaring states, transitioning states
%state TITLE, AUTHOR, DATE, ISBN, PUBLISHER
...
<TITLE> {
{Title} { print_start_tag("Book");
print_start_tag("Title");
print_element_data(yytext());
print_end_tag("Title");
}
{Slash} { yybegin(AUTHOR); }
<<EOF>> { print_end_tag("BookCatalogue");
return 0;
}
}
Declare the states
While in the
TITLE state
these are the
rules to be
used.
When a slash is
consumed while
in the TITLE
state, the lexer is
to then transition
to the AUTHOR
state.
TITLE state
Previous slide
Next slide
Back to first slide
View graphic version