Commit ceb6ad1a authored by dickelbeck's avatar dickelbeck
Browse files

* Factored out the DSNLEXER class so it can be re-used more generally. The

    constructor takes a keyword table, so it can be used for arbitrary DSN
    syntax files of your own chosing.  Simply create an enum {} with all your
    unique tokens in it.  Then create a KEYWORD table.  See SPECCTRA_DB::keywords[].
    The reason you want an enum is to give the C++ debugger better type information
    so it can show symbolic integer symbols.
  * Factored out common richio.cpp and richio.h
    which is what DSNLEXER uses.
  * Fixed some minor issues with reading circuit descriptor from a *.dsn file.
parent 0fc7d7c1
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -4,6 +4,21 @@ KiCad ChangeLog 2009
Please add newer entries at the top, list the date and your name with
email address.


2009-Dec-10 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
++all
  * Factored out the DSNLEXER class so it can be re-used more generally.  The
    constructor takes a keyword table, so it can be used for arbitrary DSN
    syntax files of your own chosing.  Simply create an enum {} with all your
    unique tokens in it.  Then create a KEYWORD table.  See SPECCTRA_DB::keywords[].
    The reason you want an enum is to give the C++ debugger better type information
    so it can show symbolic integer symbols.
  * Factored out common richio.cpp and richio.h
    which is what DSNLEXER uses.
  * Fixed some minor issues with reading circuit descriptor from a *.dsn file.


2009-Dec-6 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
++pcbnew & gerbview
+4 −2
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ set(COMMON_SRCS
    drawframe.cpp
    drawpanel.cpp
    drawtxt.cpp
    dsnlexer.cpp
    edaappl.cpp
    eda_dde.cpp
    eda_doc.cpp
@@ -41,6 +42,7 @@ set(COMMON_SRCS
    msgpanel.cpp
    projet_config.cpp
#   pyhandler.cpp
    richio.cpp
    selcolor.cpp
    string.cpp
    toolbars.cpp
+99 −98
Original line number Diff line number Diff line
@@ -11,14 +11,6 @@
#define BUILD_VERSION "(2009-12-05-unstable)"


#ifdef HAVE_SVN_VERSION
#include "version.h"
wxString g_BuildVersion( wxT( KICAD_SVN_VERSION ) );
#else
wxString g_BuildVersion( wxT( BUILD_VERSION ) );
#endif


#if defined(HAVE_SVN_VERSION) || defined(HAVE_SVN_REVISION)
#  include "version.h"
#ifndef KICAD_ABOUT_VERSION
@@ -30,6 +22,15 @@ wxString g_BuildAboutVersion( wxT( BUILD_VERSION ) );
#endif


/** Function GetAboutBuildVersion()
 * Return custom build date for about dialog
 */
wxString GetAboutBuildVersion()
{
    return g_BuildAboutVersion;
}


/**********************************/
wxString SetMsg( const wxString& msg )
/**********************************/
+11 −9
Original line number Diff line number Diff line
@@ -118,6 +118,17 @@ StructColors ColorRefs[NBCOLOR] =
};


#define BUILD_VERSION "(2009-12-05-unstable)"


#ifdef HAVE_SVN_VERSION
#include "version.h"
wxString g_BuildVersion( wxT( KICAD_SVN_VERSION ) );
#else
wxString g_BuildVersion( wxT( BUILD_VERSION ) );
#endif


/** Function GetBuildVersion()
 * Return the build date
 */
@@ -127,15 +138,6 @@ wxString GetBuildVersion()
}


/** Function GetAboutBuildVersion()
 * Return custom build date for about dialog
 */
wxString GetAboutBuildVersion()
{
    return g_BuildAboutVersion;
}


/** function SetLocaleTo_C_standard
 * because kicad is internationalized, switch internalization to "C" standard
 * i.e. uses the . (dot) as separator in print/read float numbers
+62 −514
Original line number Diff line number Diff line
@@ -30,433 +30,12 @@
#include <cctype>


#include "dsn.h"
#include "dsnlexer.h"

#include "fctsys.h"
#include "pcbnew.h"


/**
 * Class LEXER
 * implements a lexical analyzer for the SPECCTRA DSN file format.  It
 * reads lexical tokens from the current LINE_READER through the NextTok()
 * function.  The NextTok() function returns one of the DSN_T values.
 */


namespace DSN {


/**
 * Struct KEYWORD
 * holds a string and a DSN_T
 */
struct KEYWORD
{
    const char* name;
//    int         token;
};


//#define TOKDEF(x)    { #x, T_##x }
#define TOKDEF(x)    { #x }


// This MUST be sorted alphabetically, and also so MUST enum DSN_T {} be alphabetized.
// These MUST all be lower case because of the conversion to lowercase in findToken().
const static KEYWORD tokens[] = {
    TOKDEF(absolute),
    TOKDEF(added),
    TOKDEF(add_group),
    TOKDEF(add_pins),
    TOKDEF(allow_antenna),
    TOKDEF(allow_redundant_wiring),
    TOKDEF(amp),
    TOKDEF(ancestor),
    TOKDEF(antipad),
    TOKDEF(aperture_type),
    TOKDEF(array),
    TOKDEF(attach),
    TOKDEF(attr),
    TOKDEF(average_pair_length),
    TOKDEF(back),
    TOKDEF(base_design),
    TOKDEF(bbv_ctr2ctr),
    TOKDEF(bend_keepout),
    TOKDEF(bond),
    TOKDEF(both),
    TOKDEF(bottom),
    TOKDEF(bottom_layer_sel),
    TOKDEF(boundary),
    TOKDEF(brickpat),
    TOKDEF(bundle),
    TOKDEF(bus),
    TOKDEF(bypass),
    TOKDEF(capacitance_resolution),
    TOKDEF(capacitor),
    TOKDEF(case_sensitive),
    TOKDEF(cct1),
    TOKDEF(cct1a),
    TOKDEF(center_center),
    TOKDEF(checking_trim_by_pin),
    TOKDEF(circ),
    TOKDEF(circle),
    TOKDEF(circuit),
    TOKDEF(class),
    TOKDEF(class_class),
    TOKDEF(classes),
    TOKDEF(clear),
    TOKDEF(clearance),
    TOKDEF(cluster),
    TOKDEF(cm),
    TOKDEF(color),
    TOKDEF(colors),
    TOKDEF(comment),
    TOKDEF(comp),
    TOKDEF(comp_edge_center),
    TOKDEF(comp_order),
    TOKDEF(component),
    TOKDEF(composite),
    TOKDEF(conductance_resolution),
    TOKDEF(conductor),
    TOKDEF(conflict),
    TOKDEF(connect),
    TOKDEF(constant),
    TOKDEF(contact),
    TOKDEF(control),
    TOKDEF(corner),
    TOKDEF(corners),
    TOKDEF(cost),
    TOKDEF(created_time),
    TOKDEF(cross),
    TOKDEF(crosstalk_model),
    TOKDEF(current_resolution),
    TOKDEF(delete_pins),
    TOKDEF(deleted),
    TOKDEF(deleted_keepout),
    TOKDEF(delta),
    TOKDEF(diagonal),
    TOKDEF(direction),
    TOKDEF(directory),
    TOKDEF(discrete),
    TOKDEF(effective_via_length),
    TOKDEF(elongate_keepout),
    TOKDEF(exclude),
    TOKDEF(expose),
    TOKDEF(extra_image_directory),
    TOKDEF(family),
    TOKDEF(family_family),
    TOKDEF(family_family_spacing),
    TOKDEF(fanout),
    TOKDEF(farad),
    TOKDEF(file),
    TOKDEF(fit),
    TOKDEF(fix),
    TOKDEF(flip_style),
    TOKDEF(floor_plan),
    TOKDEF(footprint),
    TOKDEF(forbidden),
    TOKDEF(force_to_terminal_point),
    TOKDEF(forgotten),
    TOKDEF(free),
    TOKDEF(fromto),
    TOKDEF(front),
    TOKDEF(front_only),
    TOKDEF(gap),
    TOKDEF(gate),
    TOKDEF(gates),
    TOKDEF(generated_by_freeroute),
    TOKDEF(global),
    TOKDEF(grid),
    TOKDEF(group),
    TOKDEF(group_set),
    TOKDEF(guide),
    TOKDEF(hard),
    TOKDEF(height),
    TOKDEF(high),
    TOKDEF(history),
    TOKDEF(horizontal),
    TOKDEF(host_cad),
    TOKDEF(host_version),
    TOKDEF(image),
    TOKDEF(image_conductor),
    TOKDEF(image_image),
    TOKDEF(image_image_spacing),
    TOKDEF(image_outline_clearance),
    TOKDEF(image_set),
    TOKDEF(image_type),
    TOKDEF(inch),
    TOKDEF(include),
    TOKDEF(include_pins_in_crosstalk),
    TOKDEF(inductance_resolution),
    TOKDEF(insert),
    TOKDEF(instcnfg),
    TOKDEF(inter_layer_clearance),
    TOKDEF(jumper),
    TOKDEF(junction_type),
    TOKDEF(keepout),
    TOKDEF(kg),
    TOKDEF(kohm),
    TOKDEF(large),
    TOKDEF(large_large),
    TOKDEF(layer),
    TOKDEF(layer_depth),
    TOKDEF(layer_noise_weight),
    TOKDEF(layer_pair),
    TOKDEF(layer_rule),
    TOKDEF(length),
    TOKDEF(length_amplitude),
    TOKDEF(length_factor),
    TOKDEF(length_gap),
    TOKDEF(library),
    TOKDEF(library_out),
    TOKDEF(limit),
    TOKDEF(limit_bends),
    TOKDEF(limit_crossing),
    TOKDEF(limit_vias),
    TOKDEF(limit_way),
    TOKDEF(linear),
    TOKDEF(linear_interpolation),
    TOKDEF(load),
    TOKDEF(lock_type),
    TOKDEF(logical_part),
    TOKDEF(logical_part_mapping),
    TOKDEF(low),
    TOKDEF(match_fromto_delay),
    TOKDEF(match_fromto_length),
    TOKDEF(match_group_delay),
    TOKDEF(match_group_length),
    TOKDEF(match_net_delay),
    TOKDEF(match_net_length),
    TOKDEF(max_delay),
    TOKDEF(max_len),
    TOKDEF(max_length),
    TOKDEF(max_noise),
    TOKDEF(max_restricted_layer_length),
    TOKDEF(max_stagger),
    TOKDEF(max_stub),
    TOKDEF(max_total_delay),
    TOKDEF(max_total_length),
    TOKDEF(max_total_vias),
    TOKDEF(medium),
    TOKDEF(mhenry),
    TOKDEF(mho),
    TOKDEF(microvia),
    TOKDEF(mid_driven),
    TOKDEF(mil),
    TOKDEF(min_gap),
    TOKDEF(mirror),
    TOKDEF(mirror_first),
    TOKDEF(mixed),
    TOKDEF(mm),
    TOKDEF(negative_diagonal),
    TOKDEF(net),
    TOKDEF(net_number),
    TOKDEF(net_out),
    TOKDEF(net_pin_changes),
    TOKDEF(nets),
    TOKDEF(network),
    TOKDEF(network_out),
    TOKDEF(no),
    TOKDEF(noexpose),
    TOKDEF(noise_accumulation),
    TOKDEF(noise_calculation),
    TOKDEF(normal),
    TOKDEF(object_type),
    TOKDEF(off),
    TOKDEF(off_grid),
    TOKDEF(offset),
    TOKDEF(on),
    TOKDEF(open),
    TOKDEF(opposite_side),
    TOKDEF(order),
    TOKDEF(orthogonal),
    TOKDEF(outline),
    TOKDEF(overlap),
    TOKDEF(pad),
    TOKDEF(pad_pad),
    TOKDEF(padstack),
    TOKDEF(pair),
    TOKDEF(parallel),
    TOKDEF(parallel_noise),
    TOKDEF(parallel_segment),
    TOKDEF(parser),
    TOKDEF(part_library),
    TOKDEF(path),
    TOKDEF(pcb),
    TOKDEF(permit_orient),
    TOKDEF(permit_side),
    TOKDEF(physical),
    TOKDEF(physical_part_mapping),
    TOKDEF(piggyback),
    TOKDEF(pin),
    TOKDEF(pin_allow),
    TOKDEF(pin_cap_via),
    TOKDEF(pin_via_cap),
    TOKDEF(pin_width_taper),
    TOKDEF(pins),
    TOKDEF(pintype),
    TOKDEF(place),
    TOKDEF(place_boundary),
    TOKDEF(place_control),
    TOKDEF(place_keepout),
    TOKDEF(place_rule),
    TOKDEF(placement),
    TOKDEF(plan),
    TOKDEF(plane),
    TOKDEF(pn),
    TOKDEF(point),
    TOKDEF(polyline_path),      // used by freerouting.com
    TOKDEF(polygon),
    TOKDEF(position),
    TOKDEF(positive_diagonal),
    TOKDEF(power),
    TOKDEF(power_dissipation),
    TOKDEF(power_fanout),
    TOKDEF(prefix),
    TOKDEF(primary),
    TOKDEF(priority),
    TOKDEF(property),
    TOKDEF(protect),
    TOKDEF(qarc),
    TOKDEF(quarter),
    TOKDEF(radius),
    TOKDEF(ratio),
    TOKDEF(ratio_tolerance),
    TOKDEF(rect),
    TOKDEF(reduced),
    TOKDEF(region),
    TOKDEF(region_class),
    TOKDEF(region_class_class),
    TOKDEF(region_net),
    TOKDEF(relative_delay),
    TOKDEF(relative_group_delay),
    TOKDEF(relative_group_length),
    TOKDEF(relative_length),
    TOKDEF(reorder),
    TOKDEF(reroute_order_viols),
    TOKDEF(resistance_resolution),
    TOKDEF(resistor),
    TOKDEF(resolution),
    TOKDEF(restricted_layer_length_factor),
    TOKDEF(room),
    TOKDEF(rotate),
    TOKDEF(rotate_first),
    TOKDEF(round),
    TOKDEF(roundoff_rotation),
    TOKDEF(route),
    TOKDEF(route_to_fanout_only),
    TOKDEF(routes),
    TOKDEF(routes_include),
    TOKDEF(rule),
    TOKDEF(same_net_checking),
    TOKDEF(sample_window),
    TOKDEF(saturation_length),
    TOKDEF(sec),
    TOKDEF(secondary),
    TOKDEF(self),
    TOKDEF(sequence_number),
    TOKDEF(session),
    TOKDEF(set_color),
    TOKDEF(set_pattern),
    TOKDEF(shape),
    TOKDEF(shield),
    TOKDEF(shield_gap),
    TOKDEF(shield_loop),
    TOKDEF(shield_tie_down_interval),
    TOKDEF(shield_width),
    TOKDEF(side),
    TOKDEF(signal),
    TOKDEF(site),
    TOKDEF(small),
    TOKDEF(smd),
    TOKDEF(snap),
    TOKDEF(snap_angle),
    TOKDEF(soft),
    TOKDEF(source),
    TOKDEF(space_in_quoted_tokens),
    TOKDEF(spacing),
    TOKDEF(spare),
    TOKDEF(spiral_via),
    TOKDEF(square),
    TOKDEF(stack_via),
    TOKDEF(stack_via_depth),
    TOKDEF(standard),
    TOKDEF(starburst),
    TOKDEF(status),
    TOKDEF(string_quote),
    TOKDEF(structure),
    TOKDEF(structure_out),
    TOKDEF(subgate),
    TOKDEF(subgates),
    TOKDEF(substituted),
    TOKDEF(such),
    TOKDEF(suffix),
    TOKDEF(super_placement),
    TOKDEF(supply),
    TOKDEF(supply_pin),
    TOKDEF(swapping),
    TOKDEF(switch_window),
    TOKDEF(system),
    TOKDEF(tandem_noise),
    TOKDEF(tandem_segment),
    TOKDEF(tandem_shield_overhang),
    TOKDEF(terminal),
    TOKDEF(terminator),
    TOKDEF(term_only),
    TOKDEF(test),
    TOKDEF(test_points),
    TOKDEF(testpoint),
    TOKDEF(threshold),
    TOKDEF(time_length_factor),
    TOKDEF(time_resolution),
    TOKDEF(tjunction),
    TOKDEF(tolerance),
    TOKDEF(top),
    TOKDEF(topology),
    TOKDEF(total),
    TOKDEF(track_id),
    TOKDEF(turret),
    TOKDEF(type),
    TOKDEF(um),
    TOKDEF(unassigned),
    TOKDEF(unconnects),
    TOKDEF(unit),
    TOKDEF(up),
    TOKDEF(use_array),
    TOKDEF(use_layer),
    TOKDEF(use_net),
    TOKDEF(use_via),
    TOKDEF(value),
    TOKDEF(vertical),
    TOKDEF(via),
    TOKDEF(via_array_template),
    TOKDEF(via_at_smd),
    TOKDEF(via_keepout),
    TOKDEF(via_number),
    TOKDEF(via_rotate_first),
    TOKDEF(via_site),
    TOKDEF(via_size),
    TOKDEF(virtual_pin),
    TOKDEF(volt),
    TOKDEF(voltage_resolution),
    TOKDEF(was_is),
    TOKDEF(way),
    TOKDEF(weight),
    TOKDEF(width),
    TOKDEF(window),
    TOKDEF(wire),
    TOKDEF(wire_keepout),
    TOKDEF(wires),
    TOKDEF(wires_include),
    TOKDEF(wiring),
    TOKDEF(write_resolution),
    TOKDEF(x),
    TOKDEF(xy),
    TOKDEF(y),
};


static int compare( const void* a1, const void* a2 )
{
    const KEYWORD* k1 = (const KEYWORD*) a1;
@@ -467,54 +46,17 @@ static int compare( const void* a1, const void* a2 )
}


//-----<LINE_READER>------------------------------------------------------

LINE_READER::LINE_READER( FILE* aFile,  unsigned aMaxLineLength )
{
    fp = aFile;
    lineNum = 0;
    maxLineLength = aMaxLineLength;

    // the real capacity is 10 bytes larger than requested.
    capacity = aMaxLineLength + 10;

    line = new char[capacity];

    line[0] = '\0';
    length  = 0;
}
//-----<DSNLEXER>-------------------------------------------------------------

DSNLEXER::DSNLEXER( FILE* aFile, const wxString& aFilename,
    const KEYWORD* aKeywordTable, unsigned aKeywordCount ) :
        reader( aFile, 4096 )

int LINE_READER::ReadLine() throw (IOError)
{
    const char* p = fgets( line, capacity, fp );
    keywords = aKeywordTable;
    keywordCount = aKeywordCount;

    if( !p )
    {
        line[0] = 0;
        length  = 0;
    }
    else
    {
        length = strlen( line );

        if( length > maxLineLength )
            throw IOError( _("Line length exceeded") );

        ++lineNum;
    }

    return length;
}


//-----<LEXER>-------------------------------------------------------------


LEXER::LEXER( FILE* aFile, const wxString& aFilename ) :
        reader( aFile, 4096 )
{
    curTok = T_END;
    curTok = DSN_NONE;
    stringDelimiter = '"';
    filename = aFilename;

@@ -530,7 +72,7 @@ LEXER::LEXER( FILE* aFile, const wxString& aFilename ) :
}


int LEXER::findToken( const std::string& tok )
int DSNLEXER::findToken( const std::string& tok )
{
    // convert to lower case once, this should be faster than using strcasecmp()
    // for each test in compare().
@@ -540,78 +82,83 @@ int LEXER::findToken( const std::string& tok )
        lowercase += (char) tolower( *iter );

    KEYWORD search;

    search.name = lowercase.c_str();

    // a boost hashtable might be a few percent faster, depending on
    // hashtable size and quality of the hash function.

    const KEYWORD* findings = (const KEYWORD*) bsearch( &search,
                                   tokens, sizeof(tokens)/sizeof(tokens[0]),
                                   keywords, keywordCount,
                                   sizeof(KEYWORD), compare );
    if( findings )
//        return findings->token;
        return findings - tokens;
        return findings->token;
    else
        return -1;
}


const char* LEXER::GetTokenText( DSN_T aTok )
const char* DSNLEXER::Syntax( int aTok )
{
    const char* ret;

    if( aTok < 0 )
    {
    switch( aTok )
    {
        case T_NONE:
    case DSN_NONE:
        ret = "NONE";
        break;
        case T_QUOTE_DEF:
    case DSN_QUOTE_DEF:
        ret = "quoted text delimiter";
        break;
        case T_DASH:
    case DSN_DASH:
        ret = "-";
        break;
        case T_SYMBOL:
    case DSN_SYMBOL:
        ret = "symbol";
        break;
        case T_NUMBER:
    case DSN_NUMBER:
        ret = "number";
        break;
        case T_RIGHT:
    case DSN_RIGHT:
        ret = ")";
        break;
        case T_LEFT:
    case DSN_LEFT:
        ret = "(";
        break;
        case T_STRING:
    case DSN_STRING:
        ret = "quoted string";
        break;
        case T_EOF:
    case DSN_EOF:
        ret = "end of file";
        break;
    default:
        ret = "???";
    }
    }
    else
    {
        ret = tokens[aTok].name;
    }

    return ret;
}


wxString LEXER::GetTokenString( DSN_T aTok )
const char* DSNLEXER::GetTokenText( int aTok )
{
    wxString    ret;
    const char* ret;

    ret << wxT("'") << CONV_FROM_UTF8( GetTokenText(aTok) ) << wxT("'");
    if( aTok < 0 )
    {
        return Syntax( aTok );
    }
    else if( (unsigned) aTok < keywordCount )
    {
        ret = keywords[aTok].name;
    }
    else
        ret = "token too big";

    return ret;
}


void LEXER::ThrowIOError( wxString aText, int charOffset ) throw (IOError)
void DSNLEXER::ThrowIOError( wxString aText, int charOffset ) throw (IOError)
{
    aText << wxT(" ") << _("in file") << wxT(" \"") << filename
          << wxT("\" ") << _("on line") << wxT(" ") << reader.LineNumber()
@@ -633,14 +180,14 @@ static inline bool isSpace( int cc )
}


DSN_T LEXER::NextTok() throw (IOError)
int DSNLEXER::NextTok() throw (IOError)
{
    char*   cur  = next;
    char*   head = cur;

    prevTok = curTok;

    if( curTok != T_EOF )
    if( curTok != DSN_EOF )
    {
        if( cur >= limit )
        {
@@ -648,7 +195,7 @@ L_read:
            int len = readLine();
            if( len == 0 )
            {
                curTok = T_EOF;
                curTok = DSN_EOF;
                goto exit;
            }

@@ -673,7 +220,7 @@ L_read:
            goto L_read;

        // switching the string_quote character
        if( prevTok == T_string_quote )
        if( prevTok == DSN_STRING_QUOTE )
        {
            static const wxString errtxt( _("String delimiter must be a single character of ', \", or $"));

@@ -698,7 +245,7 @@ L_read:
                ThrowIOError( errtxt, CurOffset() );
            }

            curTok = T_QUOTE_DEF;
            curTok = DSN_QUOTE_DEF;
            goto exit;
        }

@@ -707,7 +254,7 @@ L_read:
            curText.clear();
            curText += *cur;

            curTok = T_LEFT;
            curTok = DSN_LEFT;
            head = cur+1;
            goto exit;
        }
@@ -717,7 +264,7 @@ L_read:
            curText.clear();
            curText += *cur;

            curTok = T_RIGHT;
            curTok = DSN_RIGHT;
            head = cur+1;
            goto exit;
        }
@@ -731,11 +278,11 @@ L_read:
            head = cur+1;
            curText.clear();
            curText += '-';
            curTok = T_DASH;
            curTok = DSN_DASH;
            goto exit;
        }

        // handle T_NUMBER
        // handle DSN_NUMBER
        if( strchr( "+-.0123456789", *cur ) )
        {
            head = cur+1;
@@ -746,7 +293,7 @@ L_read:
            {
                curText.clear();
                curText.append( cur, head );
                curTok = T_NUMBER;
                curTok = DSN_NUMBER;
                goto exit;
            }

@@ -774,12 +321,12 @@ L_read:

            ++head;     // skip over the trailing delimiter

            curTok  = T_STRING;
            curTok  = DSN_STRING;
            goto exit;
        }

        // a token we hope to find in the tokens[] array.  If not, then
        // call it a T_SYMBOL.
        // Maybe it is a token we will find in the token table.
        // If not, then call it a DSN_SYMBOL.
        {
            head = cur+1;
            while( head<limit && !isSpace( *head ) && *head!=')' && *head!='(' )
@@ -791,33 +338,33 @@ L_read:
            int found = findToken( curText );

            if( found != -1 )
                curTok = (DSN_T) found;
                curTok = found;

            else if( 0 == curText.compare( "string_quote" ) )
                curTok = DSN_STRING_QUOTE;

            else                    // unrecogized token, call it a symbol
                curTok = T_SYMBOL;
                curTok = DSN_SYMBOL;
        }
    }

exit:                   // single point of exit
exit:   // single point of exit, no returns elsewhere please.

    curOffset = cur - start;

    next = head;

    // printf("tok:\"%s\"\n", curText.c_str() );

    return curTok;
}


}   // namespace DSN



#if 0 && defined(STANDALONE)

// stand alone testing


int main( int argc, char** argv )
{

@@ -833,17 +380,18 @@ int main( int argc, char** argv )
        exit(1);
    }

    DSN::LEXER  lexer( fp, filename );
    // this won't compile without a token table.
    DSNLEXER  lexer( fp, filename );

    try
    {
        int tok;
        while( (tok = lexer.NextTok()) != DSN::T_EOF )
        while( (tok = lexer.NextTok()) != DSN_EOF )
        {
            printf( "%-3d %s\n", tok, lexer.CurText() );
        }
    }
    catch( DSN::IOError ioe )
    catch( IOError ioe )
    {
        printf( "%s\n", (const char*) ioe.errorText.mb_str() );
    }
Loading