lex_test.c revision 15a44745412679c30a6d022733925af70a38b715
6dcde6ca366549264b23e191ff01162f9dd03350David Lawrence * Copyright (C) 1998-2000 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.
15a44745412679c30a6d022733925af70a38b715David Lawrence * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
15a44745412679c30a6d022733925af70a38b715David Lawrence * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
15a44745412679c30a6d022733925af70a38b715David Lawrence * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
15a44745412679c30a6d022733925af70a38b715David Lawrence * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
15a44745412679c30a6d022733925af70a38b715David Lawrence * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
15a44745412679c30a6d022733925af70a38b715David Lawrence * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
15a44745412679c30a6d022733925af70a38b715David Lawrence * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
15a44745412679c30a6d022733925af70a38b715David Lawrence * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15a44745412679c30a6d022733925af70a38b715David Lawrence/* $Id: lex_test.c,v 1.16 2000/07/27 09:38:03 tale 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));