1*357f1050SThomas Veerman /*
2*357f1050SThomas Veerman * This file is part of flex.
3*357f1050SThomas Veerman *
4*357f1050SThomas Veerman * Redistribution and use in source and binary forms, with or without
5*357f1050SThomas Veerman * modification, are permitted provided that the following conditions
6*357f1050SThomas Veerman * are met:
7*357f1050SThomas Veerman *
8*357f1050SThomas Veerman * 1. Redistributions of source code must retain the above copyright
9*357f1050SThomas Veerman * notice, this list of conditions and the following disclaimer.
10*357f1050SThomas Veerman * 2. Redistributions in binary form must reproduce the above copyright
11*357f1050SThomas Veerman * notice, this list of conditions and the following disclaimer in the
12*357f1050SThomas Veerman * documentation and/or other materials provided with the distribution.
13*357f1050SThomas Veerman *
14*357f1050SThomas Veerman * Neither the name of the University nor the names of its contributors
15*357f1050SThomas Veerman * may be used to endorse or promote products derived from this software
16*357f1050SThomas Veerman * without specific prior written permission.
17*357f1050SThomas Veerman *
18*357f1050SThomas Veerman * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
19*357f1050SThomas Veerman * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
20*357f1050SThomas Veerman * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21*357f1050SThomas Veerman * PURPOSE.
22*357f1050SThomas Veerman */
23*357f1050SThomas Veerman
24*357f1050SThomas Veerman #include "scanner-1.h"
25*357f1050SThomas Veerman #include "scanner-2.h"
26*357f1050SThomas Veerman
27*357f1050SThomas Veerman int
main(int argc,char ** argv)28*357f1050SThomas Veerman main ( int argc, char** argv )
29*357f1050SThomas Veerman {
30*357f1050SThomas Veerman int S1_ok=1, S2_ok=1;
31*357f1050SThomas Veerman FILE * fp;
32*357f1050SThomas Veerman YY_BUFFER_STATE buff1, buff2;
33*357f1050SThomas Veerman yyscan_t scan1, scan2;
34*357f1050SThomas Veerman
35*357f1050SThomas Veerman S1_lex_init(&scan1);
36*357f1050SThomas Veerman S2_lex_init(&scan2);
37*357f1050SThomas Veerman
38*357f1050SThomas Veerman if((fp = fopen("scanner-1.tables","r")) == 0){
39*357f1050SThomas Veerman fprintf(stderr,"Could not open scanner-1.tables.\n");
40*357f1050SThomas Veerman exit(1);
41*357f1050SThomas Veerman }
42*357f1050SThomas Veerman if(S1_tables_fload(fp,scan1) != 0){
43*357f1050SThomas Veerman fprintf(stderr,"Could not load scanner-1.tables.\n");
44*357f1050SThomas Veerman exit(1);
45*357f1050SThomas Veerman }
46*357f1050SThomas Veerman fclose(fp);
47*357f1050SThomas Veerman
48*357f1050SThomas Veerman if((fp = fopen("scanner-2.tables","r")) == 0){
49*357f1050SThomas Veerman fprintf(stderr,"Could not open scanner-2.tables.\n");
50*357f1050SThomas Veerman exit(1);
51*357f1050SThomas Veerman }
52*357f1050SThomas Veerman if(S2_tables_fload(fp,scan2) != 0){
53*357f1050SThomas Veerman fprintf(stderr,"Could not load scanner-2.tables.\n");
54*357f1050SThomas Veerman exit(1);
55*357f1050SThomas Veerman }
56*357f1050SThomas Veerman fclose(fp);
57*357f1050SThomas Veerman
58*357f1050SThomas Veerman S1_set_out(stdout,scan1);
59*357f1050SThomas Veerman S2_set_out(S1_get_out(scan1),scan2);
60*357f1050SThomas Veerman
61*357f1050SThomas Veerman buff1 = S1__scan_string("foo on bar off", scan1);
62*357f1050SThomas Veerman buff2 = S2__scan_string("on blah blah off foo on bar off", scan2);
63*357f1050SThomas Veerman
64*357f1050SThomas Veerman /* scan simultaneously. */
65*357f1050SThomas Veerman while(S1_ok || S2_ok)
66*357f1050SThomas Veerman {
67*357f1050SThomas Veerman if (S1_ok)
68*357f1050SThomas Veerman S1_ok = S1_lex(scan1);
69*357f1050SThomas Veerman if (S2_ok)
70*357f1050SThomas Veerman S2_ok = S2_lex(scan2);
71*357f1050SThomas Veerman }
72*357f1050SThomas Veerman S1__delete_buffer(buff1, scan1);
73*357f1050SThomas Veerman S2__delete_buffer(buff2, scan2);
74*357f1050SThomas Veerman
75*357f1050SThomas Veerman S1_tables_destroy(scan1);
76*357f1050SThomas Veerman S2_tables_destroy(scan2);
77*357f1050SThomas Veerman
78*357f1050SThomas Veerman S1_lex_destroy(scan1);
79*357f1050SThomas Veerman S2_lex_destroy(scan2);
80*357f1050SThomas Veerman printf("TEST RETURNING OK.\n");
81*357f1050SThomas Veerman return 0;
82*357f1050SThomas Veerman }
83*357f1050SThomas Veerman
84*357f1050SThomas Veerman
85*357f1050SThomas Veerman /* vim:set tabstop=8 softtabstop=4 shiftwidth=4: */
86