home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ssvpar.zip / SSLEX.INL < prev    next >
Text File  |  1994-11-10  |  8KB  |  347 lines

  1. /*---------------------------------------------------------------------------
  2.  
  3.                Copyright (c) 1994 SandStone Software Inc.
  4.                           All rights reserved
  5.  
  6. ----------------------------------------------------------------------------*/
  7.  
  8.    SSInline SSLexExpressionList::~SSLexExpressionList( void)
  9.       {
  10.       freeSS( opTable);
  11.       }
  12.  
  13.    SSInline SSLexMark::SSLexMark( void)
  14.       {
  15.       oulMark = oulLine = oulOffset = 0;
  16.       }
  17.  
  18.    SSInline char* SSLexConsumer::lexemeBuffer( void) const
  19.       {
  20.       return opchBuff + ( SSIndex) oulStart;
  21.       }
  22.  
  23.    SSInline SSUnsigned32 SSLexConsumer::line( void) const
  24.       {
  25.       return oulLine;
  26.       }
  27.  
  28.    SSInline SSUnsigned32 SSLexConsumer::offset( void) const
  29.       {
  30.       return oulOffset;
  31.       }
  32.  
  33.    SSInline SSUnsigned32 SSLexConsumer::lexemeLength( void) const
  34.       {
  35.       return oulIndex - oulStart;
  36.       }
  37.  
  38.    SSInline SSUnsigned32 SSLexConsumer::lexemeLength( SSLexMark& qMark) const
  39.       {
  40.       return qMark.oulMark - oulStart;
  41.       }
  42.  
  43.    SSInline SSDbcsInfo& SSLexConsumer::dbcs( void) const
  44.       {
  45.       return oDbcs;
  46.       }
  47.  
  48.    SSInline SSLexConsumer::SSLexConsumerType SSLexConsumer::type( void) const
  49.       {
  50.       return oType;
  51.       }
  52.  
  53.    SSInline SSBooleanValue SSLexConsumer::endOfData( void) const
  54.       {
  55.       return oEndOfData;
  56.       }
  57.  
  58.    SSInline SSUnsigned32 SSLexConsumer::consumed( void) const
  59.       {
  60.       return oulConsumed;
  61.       }
  62.  
  63.    SSInline void SSLexConsumer::singleByte( void)
  64.       {
  65.       oulCurrent = opchBuff[ ( SSIndex) oulIndex++];
  66.       }
  67.  
  68.    SSInline void SSLexConsumer::doubleByte( void)
  69.       {
  70.       oulCurrent = dbcs().asUnsigned32( opchBuff + ( SSIndex) oulIndex);
  71.       oulIndex += 2;
  72.       }
  73.  
  74.    SSInline void SSLexConsumer::unicodeByte( void)
  75.       {
  76.       oulCurrent = *(( SSUnicode*) opchBuff[ ( SSIndex) oulIndex]);
  77.       oulIndex += 2;
  78.       }
  79.  
  80.    SSInline SSUnsigned32 SSLexConsumer::current( void) const
  81.       {
  82.       return oulCurrent;
  83.       }
  84.  
  85.    SSInline SSLexMark SSLexConsumer::mark( void)
  86.       {
  87.       SSLexMark zMark;
  88.       zMark.oulMark = oulIndex;
  89.       zMark.oulLine = oulScanLine;
  90.       zMark.oulOffset = oulScanOffset;
  91.       return zMark;
  92.       }
  93.  
  94.    SSInline void SSLexConsumer::flushStartOfLine( SSLexMark& qMark)
  95.       {
  96.       oulStart += oType == unicode ? 2 : 1;
  97.       oulLine++;
  98.       qMark.oulLine--;
  99.       oulOffset = 1;
  100.       }
  101.  
  102.    SSInline void SSLexConsumer::flushLexeme( SSLexMark& qMark)
  103.       {
  104.       oulStart = oulIndex = qMark.oulMark;
  105.       oulLine += qMark.oulLine;
  106.       oulOffset = qMark.oulOffset;
  107.       oulScanLine = 0;
  108.       oulScanOffset = qMark.oulOffset;
  109.       }
  110.  
  111.    SSInline void SSLexConsumer::flushLexeme( void)
  112.       {
  113.       oulStart = oulIndex;
  114.       oulLine += oulScanLine;
  115.       oulOffset = oulScanOffset;
  116.       oulScanLine = 0;
  117.       }
  118.  
  119.    SSInline void SSLexFileConsumer::close( void)
  120.       {
  121.       if ( opFile)
  122.          {
  123.          fclose( opFile);
  124.          opFile = 0;
  125.          }
  126.       }
  127.  
  128.    SSInline FILE* SSLexFileConsumer::file( void) const
  129.       {
  130.       return opFile;
  131.       }
  132.  
  133.    SSInline void SSLexLexeme::operator delete( void* qpBuff)
  134.       {
  135.       freeSS( qpBuff);
  136.       }
  137.  
  138.    SSInline void* SSLexLexeme::operator new( size_t qSize, SSUnsigned32 qBuff)
  139.       {
  140.       return mallocSS( qSize + qBuff + SSLexMinimumCharacterSize);
  141.       }
  142.  
  143.    SSInline void* SSLexLexeme::operator new( size_t qSize)
  144.       {
  145.       return mallocSS( qSize);
  146.       }
  147.  
  148.    SSInline void SSLexLexeme::setLength( SSUnsigned32 qulLength)
  149.       {
  150.       oulLength = qulLength;
  151.       }
  152.  
  153.    SSInline void SSLexLexeme::setType( SSLexLexeme::SSLexLexemeType qType)
  154.       {
  155.       oType = qType;
  156.       }
  157.  
  158.    SSInline void SSLexLexeme::setBuffer( char* qpchBuff)
  159.       {
  160.       opchBuff = qpchBuff;
  161.       }
  162.  
  163.    SSInline SSLexLexeme::SSLexLexeme( void) : oulLength( 0),
  164.       oulLine( 0), oulOffset( 0), oulToken( 0), opchBuff( 0),
  165.       oType( SSLexLexeme::character), oOwn( SSFalse)
  166.       {
  167.       }
  168.  
  169.    SSInline SSLexLexeme::SSLexLexeme( SSUnsigned32 qulToken) : oulLength( 0), 
  170.       oulLine( 0), oulOffset( 0), oulToken( qulToken), opchBuff( 0),
  171.       oType( SSLexLexeme::character), oOwn( SSFalse)
  172.       {
  173.       }
  174.  
  175.    SSInline SSLexLexeme::SSLexLexeme( SSUnsigned32 qulLine, SSUnsigned32
  176.       qulOffset) : oulLength( 0), oulToken( 0), oulLine( qulLine), 
  177.       oulOffset( qulOffset), opchBuff( 0), oType( SSLexLexeme::character),
  178.       oOwn( SSFalse)
  179.       {
  180.       }
  181.  
  182.    SSInline SSUnsigned32 SSLexLexeme::line( void) const
  183.       {
  184.       return oulLine;
  185.       }
  186.  
  187.    SSInline SSUnsigned32 SSLexLexeme::token( void) const
  188.       {
  189.       return oulToken;
  190.       }
  191.  
  192.    SSInline SSUnsigned32 SSLexLexeme::offset( void) const
  193.       {
  194.       return oulOffset;
  195.       }
  196.  
  197.    SSInline SSUnsigned32 SSLexLexeme::length( void) const
  198.       {
  199.       return oulLength;
  200.       }
  201.  
  202.    SSInline void SSLexLexeme::setLine( SSUnsigned32 qulLine)
  203.       {
  204.       oulLine = qulLine;
  205.       }
  206.  
  207.    SSInline void SSLexLexeme::setOffset( SSUnsigned32 qulOffset)
  208.       {
  209.       oulOffset = qulOffset;
  210.       }
  211.  
  212.    SSInline const char* SSLexLexeme::asConstChar( void) const
  213.       {
  214.       return opchBuff;
  215.       }
  216.  
  217.    SSInline char* SSLexLexeme::asChar( void) const
  218.       {
  219.       return opchBuff;
  220.       }
  221.  
  222.    SSInline SSLexLexeme::operator const char*( void)
  223.       {
  224.       return opchBuff;
  225.       }
  226.  
  227.    SSInline const SSUnicode* SSLexLexeme::asConstUnicode( void) const
  228.       {
  229.       return ( SSUnicode*) opchBuff;
  230.       }
  231.  
  232.    SSInline SSLexLexeme::operator const SSUnicode*( void)
  233.       {
  234.       return ( SSUnicode*) opchBuff;
  235.       }
  236.  
  237.    SSInline SSLexLexeme::SSLexLexemeType SSLexLexeme::type( void) const
  238.       {
  239.       return oType;
  240.       }
  241.  
  242.    SSInline SSBooleanValue SSLexLexeme::isEqualLexeme( SSLexLexeme& qLexeme) const
  243.       {
  244.       if ( length() != qLexeme.length()) return SSFalse;
  245.       return !memcmp( opchBuff, qLexeme.opchBuff, ( SSIndex) length());
  246.       }
  247.  
  248.    SSInline void* SSLexTable::table( void)
  249.       {
  250.       return opTable;
  251.       }
  252.  
  253.    SSInline SSLexTable::~SSLexTable( void)
  254.       {
  255.       for ( int i = 0; i < oulExpressionList; i++)
  256.          delete oapExpressionList[ i];
  257.       delete [] oapExpressionList;
  258.       freeSS( opTable);
  259.       }
  260.  
  261.    SSInline SSLexExpressionList::SSLexExpressionList( void* qpTable) : opTable( qpTable)
  262.       {
  263.       }
  264.  
  265.    SSInline void SSLex::setTable( SSLexTable& qTable)
  266.       {
  267.       opTable = &qTable;
  268.       pushExpressionList( *qTable.expressionList());
  269.       }
  270.  
  271.    SSInline void SSLex::setConsumer( SSLexConsumer& qConsumer)
  272.       {
  273.       opConsumer = &qConsumer;
  274.       }
  275.  
  276.    SSInline SSLexTable* SSLex::table( void) const
  277.       {
  278.       return opTable;
  279.       }
  280.  
  281.    SSInline SSLexConsumer* SSLex::consumer( void) const
  282.       {
  283.       return opConsumer;
  284.       }
  285.  
  286.    SSInline SSLexIterator& SSLex::iterator( void) const
  287.       {
  288.       return *opIterator;
  289.       }
  290.  
  291.    SSInline char* SSLexConsumer::buffer( void)
  292.       {
  293.       return opchBuff;
  294.       }
  295.  
  296.    SSInline SSUnsigned32 SSLexConsumer::bufferInc( void)
  297.       {
  298.       return oulInc;
  299.       }
  300.  
  301.    SSInline SSUnsigned32 SSLexConsumer::bufferLength( void)
  302.       {
  303.       return oulBuff;
  304.       }
  305.  
  306.    SSInline void SSLexConsumer::setBuffer( char* qpchBuff)
  307.       {
  308.       opchBuff = qpchBuff;
  309.       }
  310.  
  311.    SSInline void SSLexConsumer::setBufferInc( SSUnsigned32 qulInc)
  312.       {
  313.       oulInc = qulInc;
  314.       }
  315.  
  316.    SSInline void SSLexConsumer::setBufferLength( SSUnsigned32 qulBuff)
  317.       {
  318.       oulBuff = qulBuff;
  319.       }
  320.  
  321.    SSInline void SSLexConsumer::setEndOfData( void)
  322.       {
  323.       oEndOfData = SSTrue;
  324.       }
  325.  
  326.    SSInline SSUnsigned32 SSLex::lexemesValid( void)
  327.       {
  328.       return oulLexemesValid;
  329.       }
  330.  
  331.    SSInline void SSLexLexeme::setToken( SSUnsigned32 qulToken)
  332.       {
  333.       oulToken = qulToken;
  334.       }
  335.  
  336.    SSInline void SSLexConsumer::adjustMark( SSLexMark& qMark, 
  337.       SSBooleanValue qClear)
  338.       {
  339.       qMark.oulMark -= oulMark;
  340.       if ( qClear) oulMark = 0;
  341.       }
  342.  
  343.    SSInline void SSLexConsumer::setDataLength( SSUnsigned32 qulLength)
  344.       {
  345.       oulLength = qulLength;
  346.       }
  347.