lex_test.c revision ab023a65562e62b85a824509d829b6fad87e00b1
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
499b34cea04a46823d003d4c0520c8b03e8513cbBrian Wellington * Copyright (C) 1998-2001 Internet Software Consortium.
68d654930939926e4ddbe2b68234dd7c2da97de5Bob Halley * Permission to use, copy, modify, and distribute this software for any
68d654930939926e4ddbe2b68234dd7c2da97de5Bob Halley * purpose with or without fee is hereby granted, provided that the above
68d654930939926e4ddbe2b68234dd7c2da97de5Bob Halley * copyright notice and this permission notice appear in all copies.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * PERFORMANCE OF THIS SOFTWARE.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein/* $Id: lex_test.c,v 1.20 2005/04/27 04:56:09 sra Exp $ */
941f41d6139c868e357892869c94c4693b943373Bob Halley fprintf(stream, "NUMBER %lu", tokenp->value.as_ulong);
68d654930939926e4ddbe2b68234dd7c2da97de5Bob Halley fprintf(stream, "SPECIAL %c", tokenp->value.as_char);
1d9b3491ab3216c8f278dd821455a7a3b08ddfeeBob Halley FATAL_ERROR(__FILE__, __LINE__, "Unexpected type %d",
68d654930939926e4ddbe2b68234dd7c2da97de5Bob Halley unsigned int options = 0;
6a759e38699d133302d0df120d7afcd4af721951David Lawrence while ((c = isc_commandline_parse(argc, argv, "qmcs")) != -1) {
68d654930939926e4ddbe2b68234dd7c2da97de5Bob Halley switch (c) {
1d9b3491ab3216c8f278dd821455a7a3b08ddfeeBob Halley RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
1d9b3491ab3216c8f278dd821455a7a3b08ddfeeBob Halley RUNTIME_CHECK(isc_lex_create(mctx, 256, &lex) == ISC_R_SUCCESS);
68d654930939926e4ddbe2b68234dd7c2da97de5Bob Halley /* Set up to lex DNS master file. */
c1bfdd299587e790f59378351df66f6168f1e09eAndreas Gustafsson options = ISC_LEXOPT_DNSMULTILINE | ISC_LEXOPT_ESCAPE |
68d654930939926e4ddbe2b68234dd7c2da97de5Bob Halley isc_lex_setcomments(lex, ISC_LEXCOMMENT_DNSMASTERFILE);
68d654930939926e4ddbe2b68234dd7c2da97de5Bob Halley /* Set up to lex DNS config file. */
1d9b3491ab3216c8f278dd821455a7a3b08ddfeeBob Halley RUNTIME_CHECK(isc_lex_openstream(lex, stdin) == ISC_R_SUCCESS);
68d654930939926e4ddbe2b68234dd7c2da97de5Bob Halley while ((result = isc_lex_gettoken(lex, options, &token)) ==
68d654930939926e4ddbe2b68234dd7c2da97de5Bob Halley printf("Result: %s\n", isc_result_totext(result));