home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ssvpar.zip / SSPARSE.HLP (.txt) < prev    next >
OS/2 Help File  |  1994-11-30  |  168KB  |  7,859 lines

  1.  
  2. ΓòÉΓòÉΓòÉ 1. Visual Parse++ Programmer's Guide ΓòÉΓòÉΓòÉ
  3.  
  4. Welcome to the Visual Parse++ development system from SandStone Technology Inc. 
  5. Using this system, you can develop state-of-the-art lexical analyzers and 
  6. parsers in a fraction of the time it takes with other tools. 
  7.  
  8. The languages accepted by Visual Parse++ are the LALR(1) languages.  Visual 
  9. Parse++ supports all the constructs found in other lex and yacc tools plus some 
  10. powerful additions.  These include: 
  11.  
  12.    o A unique and sophisticated graphical debugging environment to test your 
  13.      language specification. 
  14.  
  15.    o Unicode and DBCS support.  All character sets are supported. 
  16.  
  17.    o The lexical analysis section(s) support multiple regular expression lists 
  18.      which you can 'push' and 'pop' when tokens are recognized. This makes it 
  19.      very easy to perform some context dependent processing in the lexical 
  20.      analysis phase which can greatly simplify the LALR(1) grammar. 
  21.  
  22.    o The grammar specification supports a sophisticated error recovery 
  23.      technique, called synchronization tokens, that provides reliable and 
  24.      powerful error recovery.  This is in addition to an advanced form of 
  25.      'error' tokens found in other tools. 
  26.  
  27.    o The lexical analyzer has the ability to recognize but ignore tokens 
  28.      without any extra coding on your part.  This is very useful for weeding 
  29.      out things like comments and white space.  The comment or white space 
  30.      (say) is recognized, but not passed to the parser. 
  31.  
  32.    o Complete seperation of the language specification from the application 
  33.      code.  Visual Parse++ generates tables and language bindings that you use 
  34.      to write your application.  You can develop and test your lexical analyzer 
  35.      and/or parser without any coding (other than the rule file). 
  36.  
  37.  There are 3 steps you must perform to develop a lexical analyzer and/or 
  38.  parser. 
  39.  
  40.   1. Write a rule file describing your language. Rule files are discussed in 
  41.      Rule Files 
  42.  
  43.   2. Use the graphical debugger to test your rule file.  The graphical debugger 
  44.      is described in the Visual Parse++ User's Guide. 
  45.  
  46.   3. Generate the tables and language bindings and write your application. See 
  47.      Language Bindings and Commands for more information. 
  48.  
  49.  
  50. ΓòÉΓòÉΓòÉ 2. Rule Files ΓòÉΓòÉΓòÉ
  51.  
  52.  Description 
  53.  Conventions 
  54.  %macro 
  55.  %expression 
  56.  Regular Expressions 
  57.  %prec 
  58.  %production 
  59.  Error Recovery 
  60.  Ambiguities 
  61.  Reserved Symbols 
  62.  
  63.  
  64. ΓòÉΓòÉΓòÉ 2.1. Description ΓòÉΓòÉΓòÉ
  65.  
  66. Rule files supply the specification for the language you are developing. The 
  67. languages accepted by Visual Parse++ are the LALR(1) languages.  Rule files 
  68. have a simple and clean syntax, simplifying language design. 
  69.  
  70. There are 4 sections to a rule file. 
  71.  
  72.    %macro         Define any macros used in %expression sections. See %macro 
  73.                   for more information. 
  74.  
  75.    %expression    1 or more named regular expression lists. See %expression for 
  76.                   more information. 
  77.  
  78.    %prec          Precedence information used to resolve shift/reduce 
  79.                   conflicts. See %prec for more information. 
  80.  
  81.    %production    Used to define the LALR(1) grammar. See %production for more 
  82.                   information. 
  83.  
  84.  The sections must be specified in the order indicated.  An example follows. 
  85.  
  86.       %macro
  87.         ┬╖
  88.         ┬╖
  89.       %expression exprList1
  90.         ┬╖
  91.         ┬╖
  92.       %expression exprList2
  93.         ┬╖
  94.         ┬╖
  95.       %prec
  96.         ┬╖
  97.         ┬╖
  98.       %production
  99.         ┬╖
  100.         ┬╖
  101.  
  102.  
  103. ΓòÉΓòÉΓòÉ 2.2. Conventions ΓòÉΓòÉΓòÉ
  104.  
  105. The rule file description that follows obey the following conventions. 
  106.  
  107.    o Keywords and reserved symbols are bold. 
  108.  
  109.    o Optional parameters are enclosed in braces []. 
  110.  
  111.    o A name matches the regular expression [a-z_A-Z][a-z_A-Z0-9]*. 
  112.  
  113.    o Tokens must be seperated by white space.  White space matches [ \t\n,]+. 
  114.  
  115.    o Regular expressions can be composed of any string of characters. 
  116.  
  117.    o Regular expressions and alias names must be enclosed in single quotes if 
  118.      they contain a character in the set [ \t\n/,;]. 
  119.  
  120.    o All regular expressions and alias names should be enclosed in single 
  121.      quotes (') to avoid confusion and enhance readability. 
  122.  
  123.    o Inside a quoted regular expression or alias, two consecutive quotes ('') 
  124.      represent a single quote. 
  125.  
  126.    o Parameters with multiple alternatives are lined up vertically with each 
  127.      alternative on a different line. 
  128.  
  129.    o C++ style comments are supported.  Everything after a '//' is ignored to 
  130.      end of line as well as anything enclosed in '/* ... */'. 
  131.  
  132.  
  133. ΓòÉΓòÉΓòÉ 2.3. %macro ΓòÉΓòÉΓòÉ
  134.  
  135. The %macro section is used to define any macros used in subsequent %expression 
  136. sections. This section is optional. The syntax of each line is: 
  137.  
  138.       {name}  regExpr;
  139.  
  140.  The braces are required on macro names. Regular expressions are described in 
  141.  Regular Expressions. An example is: 
  142.  
  143.       %macro
  144.  
  145.       {name}   '[a-z_A-Z][a-z_A-Z0-9]*';
  146.       {number} '[0-9]+';
  147.  
  148.  
  149. ΓòÉΓòÉΓòÉ 2.4. %expression ΓòÉΓòÉΓòÉ
  150.  
  151. Each %expression section defines a regular expression list.  Each list is 
  152. named.  The syntax is: 
  153.  
  154.       %expression name
  155.  
  156.  %expression names have their own name space, e.g.,  an %expression name can be 
  157.  the same as a regular expression name or a production label. 
  158.  
  159.  Visual Parse++ maintains a stack of %expression lists that you can %push, 
  160.  %goto, and %pop. The %push and %goto operators make the regular expression 
  161.  list the active lexical analyzer.  You can easily do a great deal of context 
  162.  dependent processing in the lexical analysis phase to simplify your grammar. 
  163.  
  164.  Each line in an %expression section has syntax: 
  165.  
  166.       regExpr name    [ alias ] [ %push name ] ;
  167.               %ignore          [ %goto name ]
  168.                                 [ %pop       ]
  169.  
  170.    regExpr        A regular expression.  Regular expressions are described in 
  171.                   Regular Expressions 
  172.  
  173.    name           Either a valid name or the reserved word %ignore. %ignore 
  174.                   tells the lexical analyzer to recognize the token, but not to 
  175.                   pass it to the parser. The name (or %ignore) is required. The 
  176.                   name is used to generate symbols used in your application 
  177.                   code to identify this regular expression. 
  178.  
  179.    alias          An alias that can be used in the %production section to aid 
  180.                   readability. An alias can be anything that would constitute a 
  181.                   valid regular expression, though they are not interpreted as 
  182.                   regular expressions. For example, '+' is a valid alias, but 
  183.                   not a valid name. The alias is not required. It is a good 
  184.                   idea to enclose all alias names in single quotes.  This will 
  185.                   make it easier to distinguish terminals from nonterminals in 
  186.                   the %production section. 
  187.  
  188.    %push name     Push the %expression list with name. 
  189.  
  190.    %pop           Pop the most recent %expression list.  Whatever is on top of 
  191.                   the expression list stack is now active. 
  192.  
  193.    %goto name     Goto the %expression list with name.  %goto  is equivalent to 
  194.                   a %pop followed by a %push. 
  195.  
  196.  If two regular expressions recognize the same language, the ambiguity is 
  197.  resolved in favor of the one that occurs later in the specification. 
  198.  
  199.  An example illustrating some of the features is: 
  200.  
  201.       %expression Main
  202.        '\/\*'                     %ignore, %push MultiLineComment;
  203.        '\/\/'                     %ignore, %push SingleLineComment;
  204.        '[ \t\n]+'                 %ignore;
  205.        '[a-z_A-Z][a-z_A-Z0-9]*'   Name;
  206.        '[0-9]+'                   Number;
  207.        'keyword'                  Keyword;
  208.  
  209.  
  210.       %expression MultiLineComment
  211.        '.'                        %ignore;
  212.        '\n'                       %ignore;
  213.        '\*\/'                     %ignore, %pop;
  214.  
  215.       %expression SingleLineComment
  216.        '.'                        %ignore;
  217.        '\n'                       %ignore, %pop;
  218.  
  219.  This example will recognize C++ like comments, names, numbers, and the 
  220.  reserved word 'keyword' seperated by whitespace.  The comments and whitespace 
  221.  are recognized but %ignored. The backslashes (\) in the regular expressions 
  222.  are required because '*' and '/' are meta-characters with special meaning in a 
  223.  regular expression.  The '\' turns off the special meaning. 
  224.  
  225.  The example also illustrates ambiguity resolution.  The string 'keyword' is 
  226.  recognized as a Name as well as a Keyword.  The Keyword occurs later in the 
  227.  list and the ambiguity is resolved in it's favor. 
  228.  
  229.  
  230. ΓòÉΓòÉΓòÉ 2.4.1. Regular Expressions ΓòÉΓòÉΓòÉ
  231.  
  232. Regular expressions are composed of normal characters and meta-characters which 
  233. have special meaning.  If the regular expression contains [ ;/,\t\n], it must 
  234. be enclosed in single quotes (').  Single quotes must also be used to recognize 
  235. a reserved symbol (%macro, %expression, ...). Two consecutive quotes ('') 
  236. represent a single quote in a quoted regular expression.  You should enclose 
  237. all regular expressions in single quotes to avoid confusion.  The 
  238. meta-characters are: 
  239.  
  240.    .              Matches any single character except '\n'. 
  241.  
  242.    [...]          Matches any character enclosed in the braces.  A range of 
  243.                   characters is indicated with a '-' (0-9, a-z, etc.).  If the 
  244.                   first character is a '^' the meaning is to match any 
  245.                   character not in the set. 
  246.  
  247.    *              Matches 0 or more of the preceding regular expression. 
  248.  
  249.    +              Matches 1 or more of the preceding regular expressions. 
  250.  
  251.    ()             Groups a series of regular expressions. 
  252.  
  253.    ^              As the first character in a regular expression, matches the 
  254.                   beginning of a line.  The regular expression will not be 
  255.                   recognized unless it is anchored at the beginning of a line. 
  256.  
  257.    $              As the last character in a regular expression, matches the 
  258.                   end of a line. The regular expression will not be recognized 
  259.                   unless it is immediately followed by a '\n'. 
  260.  
  261.    "..."          Literal match.  Turns off recognition of all meta-characters, 
  262.                   except the '\' sequences. 
  263.  
  264.    |              The 'or' operator. An infix operator that will match either 
  265.                   the left part 'or' the right part. 
  266.  
  267.    ?              Matches 0 or 1 occurences of the preceding regular 
  268.                   expression. 
  269.  
  270.    {m,n}          A postfix operator matching between m and n occurences of the 
  271.                   preceding regular expression. 
  272.  
  273.    {name}         Substitutes macro 'name' in the regular expression. 
  274.  
  275.    \              The meaning depends on what follows.  The following letters 
  276.                   have special meaning. 
  277.  
  278.       a                     BEL 
  279.  
  280.       b                     backspace 
  281.  
  282.       f                     formfeed 
  283.  
  284.       n                     new line 
  285.  
  286.       r                     carriage return 
  287.  
  288.       t                     tab 
  289.  
  290.       v                     vertical tab 
  291.  
  292.       d[0-9]+               decimal number 
  293.  
  294.       o[0-7]+               octal number 
  295.  
  296.       x[0-9a-fA-F]+         hex number 
  297.  
  298.       Any other character   The value of the character. 
  299.  
  300.  
  301. ΓòÉΓòÉΓòÉ 2.5. %prec ΓòÉΓòÉΓòÉ
  302.  
  303. The precedence section is used to resolve any shift/reduce conflicts in the 
  304. subsequent grammar.  Conflicts are discussed in Ambiguities. The %prec section 
  305. assigns precedence and associativity information to tokens (terminal symbols). 
  306.  
  307. By default tokens have precedence 0 and are %left associative. Each line has 
  308. syntax: 
  309.  
  310. number expr %left     ;
  311.             %right
  312.             %nonassoc
  313.  
  314.    number         The precedence, which must be a number. The number supplied 
  315.                   is incremented by 1 internally, reserving precedence number 
  316.                   0. 
  317.  
  318.    expr           The name or alias of a previously defined regular expression. 
  319.                   This parameter is required. 
  320.  
  321.    %left          The token is left associative. 
  322.  
  323.    %right         The token is right associative. 
  324.  
  325.    %nonassoc      The token is non associative. 
  326.  
  327.  
  328. ΓòÉΓòÉΓòÉ 2.6. %production ΓòÉΓòÉΓòÉ
  329.  
  330. The %production section defines the grammar. The %production statement syntax 
  331. is: 
  332.  
  333.       %production startSymbol
  334.  
  335.  The start symbol must be a nonterminal. 
  336.  
  337.  Grammars are made of production rules.  Each rule has the form: 
  338.  
  339.       label leftside -> [ symbol [ symbol ] ...] [ %prec expr ] ;
  340.  
  341.    label          A production label. This is used in the language bindings to 
  342.                   identify the production. Labels have their own name space. 
  343.                   In other words, a label name can be the same as a terminal or 
  344.                   nonterminal name. 
  345.  
  346.    leftside       The left side symbol.  It must be a nonterminal. 
  347.  
  348.    ->             The production separator. 
  349.  
  350.    symbol         Symbols are one of the following: 
  351.  
  352.        1. A name or alias of an entry in an %expression  list.  These are the 
  353.           terminal symbols. 
  354.  
  355.        2. The synchronization token %.  Synchronization tokens are discussed in 
  356.           Error Recovery. 
  357.  
  358.        3. The %error token.  Error tokens are discussed in Error Recovery. 
  359.  
  360.        4. A nonterminal symbol.  If it isn't one of the above, it is a 
  361.           nonterminal. 
  362.  
  363.    %prec expr     The optional precedence of the production.  A production has 
  364.                   the same precedence as the right most terminal symbol in the 
  365.                   production unless overridden by this parameter.  'expr' is 
  366.                   either a name or alias  of an entry defined in the %prec 
  367.                   section. If the production has no terminal symbol and no 
  368.                   %prec parameter, the precedence is 0. The precedence is used 
  369.                   to resolve any shift/reduce conflicts in the grammar. 
  370.                   Conflicts are discussed in Ambiguities. 
  371.  
  372.  
  373. ΓòÉΓòÉΓòÉ 3. Error Recovery ΓòÉΓòÉΓòÉ
  374.  
  375. Visual Parse++ contains an advanced form of error recovery called 
  376. synchronization tokens in addition to an enhanced type of error tokens. When 
  377. Visual Parse++ detects a syntax error, it executes the following procedure: 
  378.  
  379.   1. It searches the stack (the current context) for all tokens that can follow 
  380.      either a synchronization token '%', or an %error token.  This is the valid 
  381.      token set.  Typical recovery schemes look for only the most recent error 
  382.      token, not all error tokens (synchronization tokens don't exist in other 
  383.      recovery schemes). 
  384.  
  385.   2. It skips tokens in the input stream until it finds a token matching one in 
  386.      the valid token set. 
  387.  
  388.   3. If a token is found,  it pops states off the stack to make the matched 
  389.      token valid.  Parsing continues from this point. 
  390.  
  391.  There are several advantages to this scheme over other common error recovery 
  392.  procedures. 
  393.  
  394.   1. Synchronization tokens do not add any productions to the grammar.  You add 
  395.      the tokens (%) at points in the grammar that recovery will likely succeed. 
  396.  
  397.   2. The entire stack (current context) is searched for tokens when making the 
  398.      valid set. 
  399.  
  400.   3. Because of this, a minimum number of tokens are discarded before parsing 
  401.      proceeds. 
  402.  
  403.  A good example to use to illustrate error recovery is the rule file grammar 
  404.  itself.  The start production looks like: 
  405.  
  406.       Start -> MacroSection ExpressionSection PrecSection ProdSection;
  407.  
  408.  Each section begins with a unique keyword.  At a minimum, we would like to 
  409.  recover at the next section, e.g., if there is an error in the %prec section, 
  410.  we would like parsing to proceed when it hits a %production token. To 
  411.  accomplish this we add the following synchronization tokens to the production: 
  412.  
  413.       Start -> MacroSection % ExpressionSection % PrecSection % ProdSection;
  414.  
  415.  This is the highest level of recovery we need, but since each statement in any 
  416.  section ends in a ';', we should be able to enhance the error recovery to 
  417.  handle this common case.  We need to use an %error token in this case, not a 
  418.  synchronization token.  Let me illustrate. 
  419.  
  420.  This is what an entry in an %expression list entry looks like: 
  421.  
  422.       Expr -> ExprReg ExprAlias ExprAction ';';
  423.  
  424.  If we want parsing to proceed at the ';' token we need to add the following 
  425.  production to the grammar: 
  426.  
  427.       Expr -> %error ';';
  428.  
  429.  But why couldn't we do this ? 
  430.  
  431.       Expr -> ExprReg ExprAlias ExprAction % ';';
  432.  
  433.  This says to recover on a ';' symbol as well, but only when the parser has the 
  434.  entire context to the left of the % on the stack. In other words this will 
  435.  recover on a ; after the parser has shifted an ExprReg, an ExprAlias, and an 
  436.  ExprAction onto the stack.  The production with the %error token is not so 
  437.  picky, we merely have to be expecting an Expr for the recovery to operate 
  438.  properly. 
  439.  
  440.  The diferences between synchronization tokens (%) and %error tokens are: 
  441.  
  442.    o Error tokens add productions to the grammar.  These productions will never 
  443.      be reduced unless an error occurs. 
  444.  
  445.    o Synchronization tokens can be added to existing productions at any point 
  446.      in the development process without changing the language in any way. 
  447.  
  448.  
  449. ΓòÉΓòÉΓòÉ 4. Ambiguities ΓòÉΓòÉΓòÉ
  450.  
  451. LALR(1) grammars can generate 2 types of conflicts, shift/reduce and 
  452. reduce/reduce conflicts. 
  453.  
  454. Reduce/reduce conflicts are always resolved in favor of the production that 
  455. occurs later in the grammar. 
  456.  
  457. Shift/reduce conflicts are handled using the %prec information included in the 
  458. rule file. 
  459.  
  460. The precedence of the shift token is compared to the precedence of the 
  461. production.  As mentioned above, productions have the same precedence as the 
  462. rightmost terminal symbol in the production unless overridden by the %prec 
  463. parameter.  Productions have precedence 0 if they don't contain a terminal 
  464. symbol or %prec parameter. Tokens have precedence 0 by default also.  The 
  465. following rules resolve the conflict: 
  466.  
  467.   1. If the production or token have precedence 0, the shift is taken. 
  468.  
  469.   2. If the token precedence is greater than the production precedence, use the 
  470.      shift. 
  471.  
  472.   3. If the production precedence is greater than the token precedence, use the 
  473.      reduce. 
  474.  
  475.   4. If the precedences are equal, and the token is %left associative, use the 
  476.      reduce. 
  477.  
  478.   5. If the precedences are equal, and the token is not %left associative, use 
  479.      the shift. 
  480.  
  481.  A common example is an arithmetic expression grammar such as the following. 
  482.  
  483.       %expression Main
  484.  
  485.       '[ \n\t]+'       %ignore;
  486.       '\+'             Plus, '+';
  487.       '\-'             Minus, '-';
  488.       '\/'             Div, '/';
  489.       '\*'             Mult, '*';
  490.       '\*\*'           Power, '**';
  491.       '\('             OParen, '(';
  492.       '\)'             CParen, ')';
  493.       '[0-9]+'         Number, 'n';
  494.  
  495.       %prec
  496.  
  497.       1, '+',  %left;
  498.       1, '-',  %left;
  499.       2, '*',  %left;
  500.       2, '/',  %left;
  501.       3, '**', %right;
  502.  
  503.       %production Expr
  504.  
  505.       ExprPlus   Expr   -> Expr '+'  Expr;
  506.       ExprMinus  Expr   -> Expr '-'  Expr;
  507.       ExprMult   Expr   -> Expr '*'  Expr;
  508.       ExprPower  Expr   -> Expr '**' Expr;
  509.       ExprNested Expr   -> '(' Expr ')';
  510.       ExprNumber Expr   -> 'n';
  511.  
  512.  Without the %prec section, this grammar would generate numerous shift/reduce 
  513.  conflicts. 
  514.  
  515.  
  516. ΓòÉΓòÉΓòÉ 5. Reserved Symbols ΓòÉΓòÉΓòÉ
  517.  
  518. The following symbols are reserved in the rule file specification and should 
  519. not be used outside of their intended scope.  If they need to be recognized in 
  520. a regular expression, use single quotes (').  Regular expressions should always 
  521. be enclosed in single quotes.  Symbols starting with a % are reserved for 
  522. expansion. 
  523.  
  524.    ; 
  525.    -> 
  526.    % 
  527.    %error 
  528.    %expression 
  529.    %goto 
  530.    %left 
  531.    %macro 
  532.    %nonassoc 
  533.    %pop 
  534.    %prec 
  535.    %production 
  536.    %push 
  537.    %right 
  538.  
  539.  
  540. ΓòÉΓòÉΓòÉ 6. Language Bindings ΓòÉΓòÉΓòÉ
  541.  
  542.  Concepts 
  543.  C++ 
  544.  
  545.  
  546. ΓòÉΓòÉΓòÉ 6.1. Concepts ΓòÉΓòÉΓòÉ
  547.  
  548. After you have designed and tested your lexical analyzer and parser, Visual 
  549. Parse++ will generate the language bindings you need to develop your 
  550. application. 
  551.  
  552. There are 2 files that are common to all language bindings. 
  553.  
  554.   1. The lexical analyzer.  By default, this has the same name as the rule file 
  555.      with extension '.dfa'. 
  556.  
  557.   2. The parser.  By default, this has the same name as the rule file with 
  558.      extension '.llr'. 
  559.  
  560.  These files, sometimes referred to as tables, contain the information needed 
  561.  to control the lexing and parsing process.  The language bindings access these 
  562.  tables, regardless of the language used to implement your application. 
  563.  
  564.  
  565. ΓòÉΓòÉΓòÉ 6.2. C++ ΓòÉΓòÉΓòÉ
  566.  
  567.  Concepts 
  568.  SSLex 
  569.  SSLexTable 
  570.  SSLexLexeme 
  571.  SSLexExpressionList 
  572.  SSLexConsumer 
  573.  SSLexFileConsumer 
  574.  SSLexStringConsumer 
  575.  SSYacc 
  576.  SSYaccTable 
  577.  SSYaccStackElement 
  578.  SSException 
  579.  Reference Counting 
  580.  SSRef 
  581.  SSRefCount 
  582.  
  583.  
  584. ΓòÉΓòÉΓòÉ 6.2.1. Concepts ΓòÉΓòÉΓòÉ
  585.  
  586. The C++ classes provide a comprehensive set of classes to handle all of your 
  587. lexing and parsing needs.  In the large majority of cases, the only classes you 
  588. will need to be aware of are SSLex and SSYacc.  The only coding you will need 
  589. to perform in most cases is in the SSYacc::reduce member function generated by 
  590. Visual Parse++.  This is what a typical application looks like: 
  591.  
  592. SSLex  zLex( "file.name", "table.dfa");
  593. SSYacc zYacc( zLex, "table.llr");
  594. zYacc.parse();
  595.   ┬╖
  596.   ┬╖
  597. SSYaccStackElement* MyYaccClass::reduce( SSUnsigned32 qProd,
  598.    SSUnsigned32 qSize);
  599.    {
  600.    switch( qProd)
  601.      {
  602.      case MyYaccProduction0:
  603.      // Prod -> ...
  604.  
  605.      case MyYaccProduction1:
  606.      // Prod -> ...
  607.  
  608.      case MyYaccProduction2:
  609.      // Prod -> ...
  610.  
  611.      ┬╖
  612.      ┬╖
  613.      ┬╖
  614.      default:
  615.         break;
  616.      }
  617.    return stackElement();
  618.    }
  619.  
  620. A complete set of classes is provided for applications requiring greater 
  621. control of the lexing and parsing process. 
  622.  
  623.  
  624. ΓòÉΓòÉΓòÉ 6.2.2. SSLex ΓòÉΓòÉΓòÉ
  625.  
  626.  Concepts 
  627.  Constructors 
  628.  complete 
  629.  error 
  630.  gotoExpressionList 
  631.  isCurrentExpressionList 
  632.  operator++ 
  633.  popExpressionList 
  634.  pushExpressionList 
  635.  reset 
  636.  setTable 
  637.  setConsumer 
  638.  tokenToConstChar 
  639.  
  640.  
  641. ΓòÉΓòÉΓòÉ 6.2.2.1. Concepts ΓòÉΓòÉΓòÉ
  642.  
  643. The SSLex class is used to access the lexical analyzer. Visual Parse++ 
  644. generates a subclass of this class in the '.yh' file. 
  645.  
  646. A lexer needs two pieces of data to function, a table and a consumer.  Each of 
  647. these is represented by a class in sslex.hpp. 
  648.  
  649. The table is the '.dfa' file generated by Visual Parse++.  The associated class 
  650. is SSLexTable. This controls the lexer. 
  651.  
  652. The consumer represents the data to be lexed.  Supplied consumer classes 
  653. include a string consumer, SSLexStringConsumer and a file consumer, 
  654. SSLexFileConsumer.  There is a base class called SSLexConsumer that you can use 
  655. to construct your own specialized consumer if the need arises. 
  656.  
  657. See SSLexTable and SSLexConsumer for more information. 
  658.  
  659. The main virtual functions of interest to the programmer are complete and 
  660. error. 
  661.  
  662. The complete virtual function is called each time a token is recognized.  The 
  663. complete function returns a SSLexLexeme*.  The default function simply 
  664. allocates an SSLexLexeme and passes it back.  It is then passed to the parser. 
  665. By overriding this function, you can construct your own SSLexLexeme (or perhaps 
  666. something derived from one), and perform any special processing. 
  667.  
  668. The error virtual function is called whenever an invalid lexeme is detected. 
  669. The default function throws an SSException. 
  670.  
  671.  
  672. ΓòÉΓòÉΓòÉ 6.2.2.2. Constructors ΓòÉΓòÉΓòÉ
  673.  
  674. Signature 
  675.  
  676. SSLex::SSLex( const char* = 0);
  677. SSLex::SSLex( const char*, const char*);
  678. SSLex::SSLex( SSLexConsumer&, SSLexTable&);
  679.  
  680. You can construct a SSLex class in one of the following ways: 
  681.  
  682.   1. With a const char* representing the file name to consume.  In this case 
  683.      you must supply the table with the setTable member function ( and the 
  684.      consumer with setConsumer if the default is used). 
  685.  
  686.   2. With a const char* representing the file name to consume and a const char* 
  687.      representing the table name. 
  688.  
  689.   3. With a previously constructed SSLexConsumer and SSLexTable. 
  690.  
  691.  Example 
  692.  
  693.   SSLexTable        zTable( "table.dfa");
  694.   SSLexFileConaumer zConsumer( "file.name");
  695.  
  696.   SSLex             zLex;
  697.                     zLex.setTable( zTable);
  698.                     zLex.setConsumer( zConsumer);
  699.  
  700.   SSLex             zLex( "file.name", "table.dfa");
  701.  
  702.   SSLex             zLex( zConsumer, zTable);
  703.  
  704.  
  705. ΓòÉΓòÉΓòÉ 6.2.2.3. complete ΓòÉΓòÉΓòÉ
  706.  
  707. The complete virtual function is called each time a token is recognized. The 
  708. default complete function allocates an SSLexLexeme and returns. 
  709.  
  710. Warning: You must issue the SSLexConsumer::flushLexeme to flush the current 
  711. lexeme, if you don't use lexemeToMark to allocate the lexeme. 
  712.  
  713. Signature 
  714.  
  715. virtual SSLexLexeme* SSLex::complete(
  716.    SSLexConsumer&, SSUnsigned32, SSLexMark&);
  717.  
  718.  Parameters          Meaning 
  719.  
  720.  SSLexConsumer&      A reference to the consumer.  There are various ways to 
  721.                      construct an SSLexLexeme from an SSLexConsumer.  See 
  722.                      SSLexConsumer for more information. 
  723.  
  724.  SSUnsigned32        The token id associated with the recognized lexeme. 
  725.                      Typically, this parameter is passed to an SSLexConsumer 
  726.                      function to construct the SSLexLexeme. 
  727.  
  728.  SSLexMark&          A reference to a class that contains information that an 
  729.                      SSLexConsumer function uses to construct the SSLexLexeme. 
  730.  
  731.  Returns 
  732.  
  733.  A pointer to an SSLexLexeme or 0. If 0 is returned, the lexeme is ignored and 
  734.  lexing continues. 
  735.  
  736.  Example 
  737.  
  738.  This is the default complete virtual function: 
  739.  
  740.   SSLexLexeme* SSLex::complete( SSLexConsumer& qConsumer
  741.      SSUnsigned32 qulToken, SSLexMark& qMark)
  742.      {
  743.      return qConsumer.lexemeToMark( qMark, qulToken);
  744.      }
  745.  
  746.  
  747. ΓòÉΓòÉΓòÉ 6.2.2.4. error ΓòÉΓòÉΓòÉ
  748.  
  749. The error virtual function is called when an invalid lexeme is detected. The 
  750. default error function throws an SSException. 
  751.  
  752. Signature 
  753.  
  754. virtual SSLexLexeme* SSLex::error( SSLexConsumer&);
  755.  
  756.  Parameters          Meaning 
  757.  
  758.  SSLexConsumer&      A reference to an SSLexConsumer instance. You can get 
  759.                      information about the lexeme using SSLexConsumer member 
  760.                      functions. 
  761.  
  762.  Returns 
  763.  
  764.  An SSLexLexeme instance or 0.  Zero causes the lexeme to be ignored. If an 
  765.  SSLexLexeme instance is returned, it is processed as though it were a normal 
  766.  lexeme. 
  767.  
  768.  Example 
  769.  
  770.  This is the default error virtual function: 
  771.  
  772.   SSLexLexeme* SSLex::error( SSLexConsumer& qConsumer)
  773.      {
  774.      SSLexLexeme* zpLexeme = qConsumer.lexemeToCurrent();
  775.      throwException( SSExceptionLexError, SSLexMsgError, zpLexeme->.line(),
  776.         zpLexeme->offset(), zpLexeme->asConstChar());
  777.      return SSFalse;
  778.      }
  779.  
  780.  
  781. ΓòÉΓòÉΓòÉ 6.2.2.5. gotoExpressionList ΓòÉΓòÉΓòÉ
  782.  
  783. The gotoExpressionList function pops and then pushes an %expression list on the 
  784. expression list stack, making it active.  It performs the exact same function 
  785. as %goto does in a rule file.  See %expression for more information on %goto 
  786. and SSLexTable for more information on accessing expression lists. 
  787.  
  788. Signature 
  789.  
  790. SSBooleanValue SSLex::gotoExpressionList( SSLexExpressionList&);
  791.  
  792.  Parameters                    Meaning 
  793.  
  794.  SSLexExpressionList&          The expression list to goto.  You obtain 
  795.                                references to SSLexExpressionLists from 
  796.                                SSLexTable 
  797.  
  798.  Returns 
  799.  
  800.  Throws an SSException if the expression list stack is empty or full. 
  801.  
  802.  Example 
  803.  
  804.   #define ALexExpressionListMain 0 /* Generated in header file '.yh' */
  805.  
  806.   SSLexTable           zTable( "table.dfa");
  807.   SSLexFileConsumer    zConsumer( "file.name");
  808.   SSLex                zLex( zConsumer, zTable);
  809.   SSLexExpressionList& zExpressionList( zTable.expressionList( ALexExpressionListMain));
  810.  
  811.   zLex.gotoExpressionList( zExpressionList);
  812.  
  813.  
  814. ΓòÉΓòÉΓòÉ 6.2.2.6. isCurrentExpressionList ΓòÉΓòÉΓòÉ
  815.  
  816. The isCurrentExpressionList function queries the the top of the expression list 
  817. stack,  using the passed expression list identifier as a parameter. An 
  818. expression list is equivalent to an %expression list in a rule file.  The '.yh' 
  819. header file contains #define statements for each %expression list name.  This 
  820. function provides the ability to determine the expression list currently in 
  821. control. 
  822.  
  823. Signature 
  824.  
  825. SSBooleanValue SSLex::isCurrentExpressionList( SSUnsigned32);
  826.  
  827.  Parameters          Meaning 
  828.  
  829.  SSUnsigned32        An expression list identifier number. 
  830.  
  831.  Returns 
  832.  
  833.  An SSBooleanValue. An SSException is thrown if an invalid expression list 
  834.  identifier is passed. 
  835.  
  836.  Example 
  837.  
  838.   #define ALexExpressionListMain 0 /* Generated in header file '.yh' */
  839.  
  840.   SSLex          zLex( "file.name", "table.dfa");
  841.   SSBooleanValue zBool = zLex.isCurrentExpressionList( ALexExpressionListMain);
  842.  
  843.   if ( zBool)
  844.      {
  845.      /* Expression list ALexExpressionListMain is current */
  846.      }
  847.  
  848.  
  849. ΓòÉΓòÉΓòÉ 6.2.2.7. operator++ ΓòÉΓòÉΓòÉ
  850.  
  851. The operator++ function gets the next lexeme. SSYacc uses this function to 
  852. fetch lexemes from the input data.  This is the function to use to lex your 
  853. data if you need to access a lexical analyzer independent of a parser. 
  854.  
  855. Note: This is the postfix operator++. 
  856.  
  857. Signature 
  858.  
  859. SSLexLexeme* SSLex::operator++( int);
  860.  
  861. Returns 
  862.  
  863. An SSLexLexeme*. 0 indicates end of data. 
  864.  
  865. Example 
  866.  
  867. SSLexLexeme* zpLexeme;
  868. SSLex        zLex( "file.name", "table.dfa");
  869.  
  870. while ( zpLexeme = zLex++)
  871.    {
  872.    /* Process lexeme */
  873.    }
  874.  
  875.  
  876. ΓòÉΓòÉΓòÉ 6.2.2.8. popExpressionList ΓòÉΓòÉΓòÉ
  877.  
  878. The popExpressionList function pops the top %expression list off the expression 
  879. list stack.  It performs the exact same function as %pop does in a rule file. 
  880. See %expression for more information on %pop and SSLexTable for more 
  881. information on accessing expression lists. 
  882.  
  883. Signature 
  884.  
  885. SSBooleanValue SSLex::popExpressionList( void);
  886.  
  887. Returns 
  888.  
  889. Throws an SSException if the expression list stack is empty. 
  890.  
  891. Example 
  892.  
  893. SSLex zLex( "file.name", "table.dfa");
  894. zLex.popExpressionList();
  895.  
  896.  
  897. ΓòÉΓòÉΓòÉ 6.2.2.9. pushExpressionList ΓòÉΓòÉΓòÉ
  898.  
  899. The pushExpressionList function pushes an %expression list on the expression 
  900. list stack, making it active.  It performs the exact same function as %push 
  901. does in a rule file.  See %expression for more information on %push and 
  902. SSLexTable for more information on accessing expression lists. 
  903.  
  904. Signature 
  905.  
  906. SSBooleanValue SSLex::pushExpressionList( SSLexExpressionList&);
  907.  
  908.  Parameters                    Meaning 
  909.  
  910.  SSLexExpressionList&          The expression list to push.  You obtain 
  911.                                references to SSLexExpressionLists from 
  912.                                SSLexTable 
  913.  
  914.  Returns 
  915.  
  916.  Throws an SSException if the expression list stack is full. 
  917.  
  918.  Example 
  919.  
  920.   #define ALexExpressionListMain 0 /* Generated in header file '.yh' */
  921.  
  922.   SSLexTable           zTable( "table.dfa");
  923.   SSLexFileConsumer    zConsumer( "file.name");
  924.   SSLex                zLex( zConsumer, zTable);
  925.   SSLexExpressionList& zExpressionList( zTable.expressionList( ALexExpressionListMain));
  926.  
  927.   zLex.pushExpressionList( zExpressionList);
  928.  
  929.  
  930. ΓòÉΓòÉΓòÉ 6.2.2.10. reset ΓòÉΓòÉΓòÉ
  931.  
  932. The reset resets the lexer to its initial state. 
  933.  
  934. Signature 
  935.  
  936. void SSLex::reset( void);
  937.  
  938. Example 
  939.  
  940. zLex.reset();
  941.  
  942.  
  943. ΓòÉΓòÉΓòÉ 6.2.2.11. setTable ΓòÉΓòÉΓòÉ
  944.  
  945. The setTable function sets the active table for the lexer. 
  946.  
  947. Signature 
  948.  
  949. SSBooleanValue SSLex::setTable( const char*);
  950. SSBooleanValue SSLex::setTable( SSLexTable&);
  951.  
  952.  Parameters          Meaning 
  953.  
  954.  const char*         A table name. 
  955.  
  956.  SSLexTable&         A previously constructed SSLexTable. 
  957.  
  958.  Returns 
  959.  
  960.  Throws an SSException if an error occurs. 
  961.  
  962.  Example 
  963.  
  964.   SSLex      zLex;
  965.   SSLexTable zTable( "table.dfa");
  966.  
  967.   zLex.setTable( "table.dfa");
  968.   zLex.setTable( zTable);
  969.  
  970.  
  971. ΓòÉΓòÉΓòÉ 6.2.2.12. setConsumer ΓòÉΓòÉΓòÉ
  972.  
  973. The setConsumer function sets the active consumer for the lexer. 
  974.  
  975. Signature 
  976.  
  977. SSBooleanValue SSLex::setConsumer( const char*);
  978. SSBooleanValue SSLex::setConsumer( SSLexConsumer&);
  979.  
  980.  Parameters          Meaning 
  981.  
  982.  const char*         A file name. 
  983.  
  984.  SSLexConsumer&      A reference to a previously constructed SSLexConsumer. 
  985.  
  986.  Returns 
  987.  
  988.  Throws an SSException if an error occurs. 
  989.  
  990.  Example 
  991.  
  992.   SSLex             zLex;
  993.   SSLexFileConsumer zConsumer( "file.name");
  994.  
  995.   zLex.setConsumer( "file.name");
  996.   zLex.setConsumer( zConsumer);
  997.  
  998.  
  999. ΓòÉΓòÉΓòÉ 6.2.2.13. tokenToConstChar ΓòÉΓòÉΓòÉ
  1000.  
  1001. The tokenToConstChar function takes a token number and returns a string 
  1002. representing the token.  The string is either the name or alias of an entry in 
  1003. an %expression list.  The alias overrides the name if it is present. See 
  1004. %expression for more information. 
  1005.  
  1006. This function is genertated in the '.yh' header file for each lexer. It's main 
  1007. purpose is to format an error message.  SSYacc has a function which returns a 
  1008. list of valid tokens given a state (validLookaheads).  When an error occurs you 
  1009. can find the valid lookaheads and use this function to format a concise error 
  1010. message. See SSYacc for more information. 
  1011.  
  1012. Signature 
  1013.  
  1014. const char* SSLex::tokenToConstChar( SSUnsigned32);
  1015.  
  1016.  Parameters          Meaning 
  1017.  
  1018.  SSUnsigned32        The token number. 
  1019.  
  1020.  Returns 
  1021.  
  1022.  The string representing the token.  The string "SSLexTokenNotFound" is 
  1023.  returned if an invalid token is passed. 
  1024.  
  1025.  Example 
  1026.  
  1027.   SSLex         zLex( "file.name", "table.dfa");
  1028.   SSYacc        zYacc( zLex, "table.llr");
  1029.   SSUnsigned32  zulCount;
  1030.   SSUnsigned32* zpTokens = validLookaheads( zulState, zulCount);
  1031.  
  1032.   string zMsg( "Expected ");
  1033.   zMsg.concatenate( zLex.tokenToConstChar( zpTokens[ 0]));
  1034.   for ( int i = 1; i < zulCount; i++)
  1035.       {
  1036.       zMsg.concatenate( ", ");
  1037.       zMsg.concatenate( zLex.tokenToConstChar( zpTokens[ i]));
  1038.       }
  1039.  
  1040.  
  1041. ΓòÉΓòÉΓòÉ 6.2.3. SSLexTable ΓòÉΓòÉΓòÉ
  1042.  
  1043.  Concepts 
  1044.  Constructors 
  1045.  expressionList 
  1046.  
  1047.  
  1048. ΓòÉΓòÉΓòÉ 6.2.3.1. Concepts ΓòÉΓòÉΓòÉ
  1049.  
  1050. The SSLexTable class represents lex tables ('.dfa' files). 
  1051.  
  1052. Tables can be shared.  The main use of SSLexTable is to define static 
  1053. definitions of frequently used tables so the file will only be read once, when 
  1054. the SSLexTable table is constructed. 
  1055.  
  1056.  
  1057. ΓòÉΓòÉΓòÉ 6.2.3.2. Constructors ΓòÉΓòÉΓòÉ
  1058.  
  1059. Signature 
  1060.  
  1061. SSLexTable::SSLexTable( const char*);
  1062.  
  1063. SSLexTable instances are constructed out of a file name. 
  1064.  
  1065. Example 
  1066.  
  1067. SSLexTable zTable( "table.dfa");
  1068.  
  1069.  
  1070. ΓòÉΓòÉΓòÉ 6.2.3.3. expressionList ΓòÉΓòÉΓòÉ
  1071.  
  1072. The expressionList function return a reference to an SSLexExpressionList.  The 
  1073. reference is used on pushExpressionList and gotoExpressionList functions in 
  1074. class SSLex.  An expression list is equivalent to an %expression list in a rule 
  1075. file. 
  1076.  
  1077. Signature 
  1078.  
  1079. SSLexExpressionList* SSLexTable::expressionList( SSUnsigned32);
  1080.  
  1081.  Parameters          Meaning 
  1082.  
  1083.  SSUnsigned32        An expression list identifier defined in a '.yh' file. You 
  1084.                      must use a valid #define generated by Visual Parse++. 
  1085.  
  1086.  Returns 
  1087.  
  1088.  A pointer to the specidied expression list.  An SSException is thrown if the 
  1089.  expression list identifier is invalid. 
  1090.  
  1091.  Example 
  1092.  
  1093.   #define ALexExpressionListMain 0 /* Generated in header file '.yh' */
  1094.  
  1095.   SSLexTable     zTable( "table.dfa");
  1096.   SSLexExpressionList& zExpressionList( zTable.expressionList( ALexExpressionListMain));
  1097.  
  1098.  
  1099. ΓòÉΓòÉΓòÉ 6.2.4. SSLexLexeme ΓòÉΓòÉΓòÉ
  1100.  
  1101.  Concepts 
  1102.  Constructors 
  1103.  asChar 
  1104.  asConstChar 
  1105.  asConstUnicode 
  1106.  asUnsigned32 
  1107.  isEqualLexeme 
  1108.  length 
  1109.  line 
  1110.  offset 
  1111.  operator const char* 
  1112.  operator const Unicode* 
  1113.  operator delete 
  1114.  operator new 
  1115.  setBuffer 
  1116.  setLength 
  1117.  setLine 
  1118.  setOffset 
  1119.  setToken 
  1120.  token 
  1121.  type 
  1122.  
  1123.  
  1124. ΓòÉΓòÉΓòÉ 6.2.4.1. Concepts ΓòÉΓòÉΓòÉ
  1125.  
  1126. The SSLexLexeme class represent the lexemes or tokens in your data that are 
  1127. recognized by an instance of SSLex. 
  1128.  
  1129. This class passes information between instances of the SSLex and SSYacc 
  1130. classes. 
  1131.  
  1132. You can access lexemes through SSYacc member functions, usually in your reduce 
  1133. virtual function. 
  1134.  
  1135. See also the SSLex functions complete and operator++. 
  1136.  
  1137. Note: You must implement the refFree virtual function if you derive a class 
  1138. from SSLexLexeme.  Reference counting is used to control the lifetime of 
  1139. SSLexLexemes.  See SSRefCount and Reference Counting for more information. 
  1140.  
  1141.  
  1142. ΓòÉΓòÉΓòÉ 6.2.4.2. Constructors ΓòÉΓòÉΓòÉ
  1143.  
  1144. Signature 
  1145.  
  1146. SSLexLexeme::SSLexLexeme( void);
  1147. SSLexLexeme::SSLexLexeme( SSUnsigned32);
  1148. SSLexLexeme::SSLexLexeme( SSLexConsumer&,
  1149.    SSUnsigned32, SSLexMark&, SSBooleanValue = SSFalse);
  1150. SSLexLexeme::SSLexLexeme( SSUnsigned32, SSUnsigned32, const char*,
  1151.    SSUnsigned32, SSUnsigned32, SSBooleanValue = SSFalse);
  1152. SSLexLexeme::SSLexLexeme( SSUnsigned32, SSUnsigned32, const SSUnicode*,
  1153.    SSUnsigned32, SSUnsigned32, SSBooleanValue = SSFalse);
  1154.  
  1155. Instances of SSLexLexeme can be constructed in the following ways: 
  1156.  
  1157.   1. With no parameters. 
  1158.  
  1159.   2. From a token number. 
  1160.  
  1161.   3. From an SSLexConsumer&, SSUnsigned32, an SSLexMark& and an SSBooleanValue 
  1162.      which defaults to SSFalse.  Note that these parameters are the same as 
  1163.      those passed on the SSLex virtual function complete. The SSBooleanValue is 
  1164.      used to indicate if the overloaded new function, which accepts a length 
  1165.      parameter, was used to allocate the instance. 
  1166.  
  1167.   4. From a length, token number, data pointer (const char*), line number, line 
  1168.      offset and an SSBooleanValue. The SSBooleanValue is used to indicate if 
  1169.      the overloaded new function, which accepts a length parameter, was used to 
  1170.      allocate the instance. 
  1171.  
  1172.   5. From a length, token number, data pointer (const SSUnicode*), line number, 
  1173.      line offset and an SSBooleanValue. The SSBooleanValue is used to indicate 
  1174.      if the overloaded new function, which accepts a length parameter, was used 
  1175.      to allocate the instance. 
  1176.  
  1177.  Warning: If you use SSLexLexeme as a base class,  do not use the new operator 
  1178.  accepting a length in conjunction with an SSLexLexeme constructor initializer 
  1179.  with a SSTrue parameter.  In this case, the data will be copied to the end of 
  1180.  what the base class considers the end of the SSLexLexeme.  This is not 
  1181.  necessarily the correct offset and you may overlay a part of your new class. 
  1182.  
  1183.  Example 
  1184.  
  1185.   SSUnsigned32 zulLine = zConsumer.line();
  1186.   SSUnsigned32 zulOffset = zConsumer.offset();
  1187.   SSUnsigned32 zulToken = zFinal.token();
  1188.   SSUnsigned32 zulLength = strlen( "Test lexeme");
  1189.   SSUnsigned32 zpchData = "Test lexeme";
  1190.  
  1191.   SSLexLexeme zpLexeme = new( zulLength)
  1192.      SSLexLexeme( zulLength, zulToken, zpchData, zulLine, zulOffset, SSTrue);
  1193.  
  1194.  
  1195. ΓòÉΓòÉΓòÉ 6.2.4.3. asChar ΓòÉΓòÉΓòÉ
  1196.  
  1197. The asChar function returns the buffer pointer as a char*. 
  1198.  
  1199. Signature 
  1200.  
  1201. char* SSLexLexeme::asChar( void);
  1202.  
  1203. Returns 
  1204.  
  1205. The buffer pointer. 
  1206.  
  1207. Example 
  1208.  
  1209. char* zpchLexeme = zLexeme.asChar();
  1210.  
  1211.  
  1212. ΓòÉΓòÉΓòÉ 6.2.4.4. asConstChar ΓòÉΓòÉΓòÉ
  1213.  
  1214. The asConstChar function returns the buffer pointer as a const char*. 
  1215.  
  1216. Signature 
  1217.  
  1218. const char* SSLexLexeme::asConstChar( void);
  1219.  
  1220. Returns 
  1221.  
  1222. The buffer pointer. 
  1223.  
  1224. Example 
  1225.  
  1226. const char* zpchLexeme = zLexeme.asConstChar();
  1227.  
  1228.  
  1229. ΓòÉΓòÉΓòÉ 6.2.4.5. asConstUnicode ΓòÉΓòÉΓòÉ
  1230.  
  1231. The asConstUnicode function returns the buffer pointer as a const SSUnicode*. 
  1232.  
  1233. Signature 
  1234.  
  1235. const SSUnicode* SSLexLexeme::asChar( void);
  1236.  
  1237. Returns 
  1238.  
  1239. The buffer pointer. 
  1240.  
  1241. Example 
  1242.  
  1243. const SSUnicode* zpLexeme = zLexeme.asConstUnicode();
  1244.  
  1245.  
  1246. ΓòÉΓòÉΓòÉ 6.2.4.6. asUnsigned32 ΓòÉΓòÉΓòÉ
  1247.  
  1248. The asUnsigned32 function converts the lexeme to an SSUnsigned32. 
  1249.  
  1250. Signature 
  1251.  
  1252. SSUnsigned32 SSLexLexeme::asUnsigned32( SSBooleanValue&);
  1253.  
  1254.  Parameters          Meaning 
  1255.  
  1256.  SSBooleanValue&     A reference to an SSBooleanValue that is updated with an 
  1257.                      overflow indication.  SSTrue means overflow occurred. 
  1258.  
  1259.  Returns 
  1260.  
  1261.  The converted value and an overflow indication.  The value is 0 if the lexeme 
  1262.  is not numeric. 
  1263.  
  1264.  Example 
  1265.  
  1266.   SSBooleanValue zOverflow;
  1267.   SSUnsigned32   zulLexeme = zLexeme.asUnsigned32( zOverFlow);
  1268.   if ( zOverFlow)
  1269.      {
  1270.      /* Overflow occurred */
  1271.      }
  1272.  
  1273.  
  1274. ΓòÉΓòÉΓòÉ 6.2.4.7. isEqualLexeme ΓòÉΓòÉΓòÉ
  1275.  
  1276. The isEqualLexeme function tests the equality of the data portion of the 
  1277. SSLexLexeme. 
  1278.  
  1279. Signature 
  1280.  
  1281. SSBooleanValue SSLexLexeme::isEqualLexeme( SSLexLexeme&);
  1282.  
  1283.  Parameters          Meaning 
  1284.  
  1285.  SSLexLexeme&        A reference to an SSLexLexeme (the comparand). 
  1286.  
  1287.  Returns 
  1288.  
  1289.  The result of the comparison. SSTrue indicates the lexemes are equal. 
  1290.  
  1291.  Example 
  1292.  
  1293.   SSBooleanValue zResult = zLexeme.isEqualLexeme( zCompare);
  1294.   if ( zResult)
  1295.      {
  1296.      /* Lexemes are equal */
  1297.      }
  1298.  
  1299.  
  1300. ΓòÉΓòÉΓòÉ 6.2.4.8. length ΓòÉΓòÉΓòÉ
  1301.  
  1302. The length function returns the length of the lexeme. 
  1303.  
  1304. Signature 
  1305.  
  1306. SSUnsigned32 SSLexLexeme::length( void);
  1307.  
  1308. Returns 
  1309.  
  1310. The lexeme length. 
  1311.  
  1312. Example 
  1313.  
  1314. SSUnsigned32 zulLength = zLexeme.length();
  1315.  
  1316.  
  1317. ΓòÉΓòÉΓòÉ 6.2.4.9. line ΓòÉΓòÉΓòÉ
  1318.  
  1319. The line function returns the line number of the lexeme. 
  1320.  
  1321. Signature 
  1322.  
  1323. SSUnsigned32 SSLexLexeme::line( void);
  1324.  
  1325. Returns 
  1326.  
  1327. The line number. 
  1328.  
  1329. Example 
  1330.  
  1331. SSUnsigned32 zulLine = zLexeme.line();
  1332.  
  1333.  
  1334. ΓòÉΓòÉΓòÉ 6.2.4.10. offset ΓòÉΓòÉΓòÉ
  1335.  
  1336. The offset function returns the line offset of the lexeme. 
  1337.  
  1338. Signature 
  1339.  
  1340. SSUnsigned32 SSLexLexeme::offset( void);
  1341.  
  1342. Returns 
  1343.  
  1344. The lexeme offset. 
  1345.  
  1346. Example 
  1347.  
  1348. SSUnsigned32 zulLength = zLexeme.offset();
  1349.  
  1350.  
  1351. ΓòÉΓòÉΓòÉ 6.2.4.11. operator const char* ΓòÉΓòÉΓòÉ
  1352.  
  1353. The conversion function operator const char*. 
  1354.  
  1355. Signature 
  1356.  
  1357. SSLexLexeme::operator const char*( void);
  1358.  
  1359. Returns 
  1360.  
  1361. The lexeme as a const char*. 
  1362.  
  1363. Example 
  1364.  
  1365. const char* zpchLexeme = zLexeme;
  1366.  
  1367.  
  1368. ΓòÉΓòÉΓòÉ 6.2.4.12. operator const SSUnicode* ΓòÉΓòÉΓòÉ
  1369.  
  1370. The conversion function operator const SSUnicode*. 
  1371.  
  1372. Signature 
  1373.  
  1374. SSLexLexeme::operator const char*( void);
  1375.  
  1376. Returns 
  1377.  
  1378. The lexeme as a const SSUnicode*. 
  1379.  
  1380. Example 
  1381.  
  1382. const SSUnicode* zpLexeme = zLexeme;
  1383.  
  1384.  
  1385. ΓòÉΓòÉΓòÉ 6.2.4.13. operator delete ΓòÉΓòÉΓòÉ
  1386.  
  1387. The overloaded delete function frees a lexeme allocated with one of the 
  1388. overloaded new functions. 
  1389.  
  1390. Signature 
  1391.  
  1392. void SSLexLexeme::operator delete( void*);
  1393.  
  1394. Example 
  1395.  
  1396. delete zpLexeme;
  1397.  
  1398.  
  1399. ΓòÉΓòÉΓòÉ 6.2.4.14. operator new ΓòÉΓòÉΓòÉ
  1400.  
  1401. The overloaded new function allocates an SSLexLexeme. The constructors of 
  1402. SSLexLexeme accept a parameter indicating if the non-default new operator was 
  1403. used to allocate the SSLexLexeme.  If so, no new buffer is allocated, the data 
  1404. is copied to the preallocated space at the end of the returned area. 
  1405.  
  1406. Warning: If you use SSLexLexeme as a base class,  do not use the new operator 
  1407. accepting a length in conjunction with an SSLexLexeme constructor initializer 
  1408. with a SSTrue parameter.  In this case, the data will be copied to the end of 
  1409. what the base class considers the end of the SSLexLexeme.  This is not 
  1410. necessarily the correct offset and you may overlay a part of your new class. 
  1411.  
  1412. Signature 
  1413.  
  1414. void* SSLexLexeme::operator new( size_t);
  1415. void* SSLexLexeme::operator new( size_t, SSUnsigned32);
  1416.  
  1417.  Parameters          Meaning 
  1418.  
  1419.  size_t              The size of an SSLexLexeme.  Passed in by the run-time 
  1420.                      system. 
  1421.  
  1422.  SSUnsigned32        The size of the data portion of the lexeme. 
  1423.  
  1424.  Example 
  1425.  
  1426.   SSUnsigned32 zulLine = zConsumer.line();
  1427.   SSUnsigned32 zulOffset = zConsumer.offset();
  1428.   SSUnsigned32 zulToken = zFinal.token();
  1429.   SSUnsigned32 zulLength = strlen( "Test lexeme");
  1430.   SSUnsigned32 zpchData = "Test lexeme";
  1431.  
  1432.   SSLexLexeme zpLexeme = new( zulLength)
  1433.      SSLexLexeme( zulLength, zulToken, zpchData, zulLine, zulOffset, SSTrue);
  1434.  
  1435.  
  1436. ΓòÉΓòÉΓòÉ 6.2.4.15. setBuffer ΓòÉΓòÉΓòÉ
  1437.  
  1438. The setBuffer function sets the buffer pointer. 
  1439.  
  1440. Signature 
  1441.  
  1442. void SSLexLexeme::setBuffer( char*);
  1443.  
  1444.  Parameters          Meaning 
  1445.  
  1446.  char*               A buffer pointer. 
  1447.  
  1448.  Example 
  1449.  
  1450.   char* zpchBuffer = "Buffer";
  1451.   zLexeme.setBuffer( zpchBuffer);
  1452.  
  1453.  
  1454. ΓòÉΓòÉΓòÉ 6.2.4.16. setLength ΓòÉΓòÉΓòÉ
  1455.  
  1456. The setLength function sets the lexeme length. 
  1457.  
  1458. Signature 
  1459.  
  1460. void SSLexLexeme::setLength( SSUnsigned32);
  1461.  
  1462.  Parameters          Meaning 
  1463.  
  1464.  SSUnsigned32        The buffer length. 
  1465.  
  1466.  Example 
  1467.  
  1468.   char*        zpchBuffer = "Buffer";
  1469.   SSUnsigned32 zulLength = strlen( "Buffer");
  1470.  
  1471.   zLexeme.setLength( zulLength);
  1472.   zLexeme.setBuffer( zpchBuffer);
  1473.  
  1474.  
  1475. ΓòÉΓòÉΓòÉ 6.2.4.17. setLine ΓòÉΓòÉΓòÉ
  1476.  
  1477. The setLine function sets the lexeme line nnumber. 
  1478.  
  1479. Signature 
  1480.  
  1481. void SSLexLexeme::setLine( SSUnsigned32);
  1482.  
  1483.  Parameters          Meaning 
  1484.  
  1485.  SSUnsigned32        The line number. 
  1486.  
  1487.  Example 
  1488.  
  1489.   zLexeme.setLine( 10);
  1490.  
  1491.  
  1492. ΓòÉΓòÉΓòÉ 6.2.4.18. setOffset ΓòÉΓòÉΓòÉ
  1493.  
  1494. The setOffset function sets the lexeme line offset. 
  1495.  
  1496. Signature 
  1497.  
  1498. void SSLexLexeme::setOffset( SSUnsigned32);
  1499.  
  1500.  Parameters          Meaning 
  1501.  
  1502.  SSUnsigned32        The line offset. 
  1503.  
  1504.  Example 
  1505.  
  1506.   zLexeme.setOffset( 1);
  1507.  
  1508.  
  1509. ΓòÉΓòÉΓòÉ 6.2.4.19. setToken ΓòÉΓòÉΓòÉ
  1510.  
  1511. The setToken function sets the lexeme token. 
  1512.  
  1513. Signature 
  1514.  
  1515. void SSLexLexeme::setToken( SSUnsigned32);
  1516.  
  1517.  Parameters          Meaning 
  1518.  
  1519.  SSUnsigned32        The token. 
  1520.  
  1521.  Example 
  1522.  
  1523.   zLexeme.setToken( 50);
  1524.  
  1525.  
  1526. ΓòÉΓòÉΓòÉ 6.2.4.20. token ΓòÉΓòÉΓòÉ
  1527.  
  1528. The token function returns the token. 
  1529.  
  1530. Signature 
  1531.  
  1532. SSUnsigned32 SSLexLexeme::setToken( void);
  1533.  
  1534. Returns 
  1535.  
  1536. The token number. 
  1537.  
  1538. Example 
  1539.  
  1540. SSUnsigned32 zulToken = zLexeme.token();
  1541.  
  1542.  
  1543. ΓòÉΓòÉΓòÉ 6.2.4.21. type ΓòÉΓòÉΓòÉ
  1544.  
  1545. The type function returns the lexeme type.  The lexeme type is an embedded enum 
  1546. SSLexLexemeType.  The possible values are character and unicode. 
  1547.  
  1548. Signature 
  1549.  
  1550. SSLexLexeme::SSLexLexemeType SSLexLexeme::type( void);
  1551.  
  1552. Returns 
  1553.  
  1554. The lexeme type, character or unicode. 
  1555.  
  1556. Example 
  1557.  
  1558. SSLexLexeme::SSLexLexemeType zType = zLexeme.type();
  1559.  
  1560.  
  1561. ΓòÉΓòÉΓòÉ 6.2.5. SSLexExpressionList ΓòÉΓòÉΓòÉ
  1562.  
  1563.  Concepts 
  1564.  Constructors 
  1565.  
  1566.  
  1567. ΓòÉΓòÉΓòÉ 6.2.5.1. Concepts ΓòÉΓòÉΓòÉ
  1568.  
  1569. The SSLexExpressionList class represents an %expression list in a rule file. 
  1570.  
  1571. The SSLex class maintains a stack of expression lists.  The top of the stack is 
  1572. the current %expression list in use. 
  1573.  
  1574. You can manipulate expression lists with the SSLex functions 
  1575. pushExpressionList, gotoExpressionList, and popExpressionList. 
  1576.  
  1577.  
  1578. ΓòÉΓòÉΓòÉ 6.2.5.2. Constructors ΓòÉΓòÉΓòÉ
  1579.  
  1580. Instances of this class are never contructed by the programmer.  The SSLexTable 
  1581. class returns references to SSLexExpressionLists. 
  1582.  
  1583.  
  1584. ΓòÉΓòÉΓòÉ 6.2.6. SSLexConsumer ΓòÉΓòÉΓòÉ
  1585.  
  1586.  Concepts 
  1587.  Constructors 
  1588.  addBuffer 
  1589.  buffer 
  1590.  bufferInc 
  1591.  bufferLength 
  1592.  expandBuffer 
  1593.  flushLexeme 
  1594.  lexemeBuffer 
  1595.  lexemeLength 
  1596.  lexemeToCurrent 
  1597.  lexemeToMark 
  1598.  line 
  1599.  nextBuffer 
  1600.  offset 
  1601.  setBuffer 
  1602.  setBufferInc 
  1603.  setBufferLength 
  1604.  setDataLength 
  1605.  setEndOfData 
  1606.  shiftBuffer 
  1607.  type 
  1608.  
  1609.  
  1610. ΓòÉΓòÉΓòÉ 6.2.6.1. Concepts ΓòÉΓòÉΓòÉ
  1611.  
  1612. The SSLexConsumer class is the base class for data consumers.  A consumer is 
  1613. required for each instance of SSLex. 
  1614.  
  1615. Two consumers are provided, SSLexFileConsumer and SSLexStringConsumer. 
  1616.  
  1617. Use this class as your base class if you need to write a specialized consumer. 
  1618. You must implement the pure virtual function nextBuffer. 
  1619.  
  1620. An SSLexConsumer supports a buffer that can hold either 1 or 2 byte unsigned 
  1621. integers.  Units of the specified length are consumed by an instance of SSLex. 
  1622.  
  1623.  
  1624. ΓòÉΓòÉΓòÉ 6.2.6.2. Constructors ΓòÉΓòÉΓòÉ
  1625.  
  1626. Note: This is an abstract class. 
  1627.  
  1628. SSLexConsumer::SSLexConsumer( SSLexConsumerType);
  1629.  
  1630. Instances of SSLexConsumer are contructed from the embedded enum 
  1631. SSLexConsumerType.  Valid types are: 
  1632.  
  1633.  binary              The buffer holds single byte units.  No DBCS checking is 
  1634.                      done. 
  1635.  
  1636.  character           The buffer holds single byte units.  DBCS checking is 
  1637.                      performed. 
  1638.  
  1639.  unicode             The buffer holds units interpreted as 16-bit unsigned 
  1640.                      integers. 
  1641.  
  1642.  
  1643. ΓòÉΓòÉΓòÉ 6.2.6.3. addBuffer ΓòÉΓòÉΓòÉ
  1644.  
  1645. The addBuffer function adds data to the consumer buffer. The shiftBuffer and 
  1646. expandBuffer function are used to make room for the data. Do not use this 
  1647. function from the nextBuffer virtual function. 
  1648.  
  1649. Signature 
  1650.  
  1651. void SSLexConsumer::addBuffer( char*, SSUnsigned32);
  1652.  
  1653.  Parameters          Meaning 
  1654.  
  1655.  char*               The data pointer. 
  1656.  
  1657.  SSUnsigned32        The data length. 
  1658.  
  1659.  Example 
  1660.  
  1661.   zConsumer.addBuffer( "Data", strlen( "Data"));
  1662.  
  1663.  
  1664. ΓòÉΓòÉΓòÉ 6.2.6.4. buffer ΓòÉΓòÉΓòÉ
  1665.  
  1666. The buffer function returns the buffer address as a char*.  It is set with the 
  1667. setBuffer function. 
  1668.  
  1669. Signature 
  1670.  
  1671. char* SSLexConsumer::buffer( void);
  1672.  
  1673. Returns 
  1674.  
  1675. The buffer pointer as a char*. 
  1676.  
  1677. Example 
  1678.  
  1679. char* zpchBuffer = zConsumer.buffer();
  1680.  
  1681.  
  1682. ΓòÉΓòÉΓòÉ 6.2.6.5. bufferInc ΓòÉΓòÉΓòÉ
  1683.  
  1684. The bufferInc function returns the buffer increment.  The increment is used to 
  1685. expand the buffer if necessary.  It is set with the setBufferInc function. 
  1686.  
  1687. Signature 
  1688.  
  1689. SSUnsigned32 SSLexConsumer::bufferInc( void);
  1690.  
  1691. Returns 
  1692.  
  1693. The buffer increment. 
  1694.  
  1695. Example 
  1696.  
  1697. SSUnsigned32 zulInc = zConsumer.bufferInc();
  1698.  
  1699.  
  1700. ΓòÉΓòÉΓòÉ 6.2.6.6. bufferLength ΓòÉΓòÉΓòÉ
  1701.  
  1702. The bufferLength function returns the buffer length. It is set with the 
  1703. setBufferLength function. 
  1704.  
  1705. Signature 
  1706.  
  1707. SSUnsigned32 SSLexConsumer::bufferLength( void);
  1708.  
  1709. Returns 
  1710.  
  1711. The buffer length. 
  1712.  
  1713. Example 
  1714.  
  1715. SSUnsigned32 zulLength = zConsumer.bufferLength();
  1716.  
  1717.  
  1718. ΓòÉΓòÉΓòÉ 6.2.6.7. expandBuffer ΓòÉΓòÉΓòÉ
  1719.  
  1720. The expandBuffer function expands the consumer buffer. Typically, this function 
  1721. is used in your nextBuffer virtual function to make room for more data.  See 
  1722. the shiftBuffer function also. 
  1723.  
  1724. Signature 
  1725.  
  1726. SSBooleanValue SSLexConsumer::expandBuffer( SSUnsigned32&,
  1727.    SSUnsigned32&);
  1728.  
  1729.  Parameters          Meaning 
  1730.  
  1731.  SSUnsigned32&       A reference that is updated with the offset from the 
  1732.                      beginning of the buffer (see buffer) of the area to fill. 
  1733.  
  1734.  SSUnsigned32&       A reference that is updated with the length of the 
  1735.                      available area. 
  1736.  
  1737.  Returns 
  1738.  
  1739.  A success indicator.  SSFalse indicates the expansion was successful. 
  1740.  
  1741.  Example 
  1742.  
  1743.  The following example assumes you are running in a nextBuffer virtual 
  1744.  function. 
  1745.  
  1746.   SSUnsigned32 zulFill;
  1747.   SSUnsigned32 zulStart;
  1748.   SSBooleanValue zResult = expandBuffer( zulStart, zulFill);
  1749.   if ( !zResult)
  1750.      {
  1751.      char* zpchStart = buffer() + zulStart;
  1752.      /* Read data into zpchBuffer with length zulFill */
  1753.      }
  1754.  
  1755.  
  1756. ΓòÉΓòÉΓòÉ 6.2.6.8. flushLexeme ΓòÉΓòÉΓòÉ
  1757.  
  1758. The flushLexeme flushes the current lexeme from the consumer buffer.  If you 
  1759. don't supply a SSLexMark, all scanned data is flushed from the buffer, not just 
  1760. the current lexeme. 
  1761.  
  1762. Usually, the SSLex::complete function is the only place you will use this 
  1763. function. 
  1764.  
  1765. Signature 
  1766.  
  1767. void SSLexConsumer::flushLexeme( void);
  1768. void SSLexConsumer::flushLexeme( SSLexMark&);
  1769.  
  1770.  Parameters          Meaning 
  1771.  
  1772.  SSLexMark&          A reference to a SSLexMark.  A SSLexMark is passed in as a 
  1773.                      parameter of the SSLex::complete virtual function. 
  1774.  
  1775.  Example 
  1776.  
  1777.  This examples assumes you are running in the SSLex::complete virtual function. 
  1778.  
  1779.   flushLexeme( qMark);
  1780.  
  1781.  
  1782. ΓòÉΓòÉΓòÉ 6.2.6.9. lexemeBuffer ΓòÉΓòÉΓòÉ
  1783.  
  1784. The lexemeBuffer function returns the address of the start of the current 
  1785. lexeme as a char*. 
  1786.  
  1787. Signature 
  1788.  
  1789. char* SSLexConsumer::lexemeBuffer( void);
  1790.  
  1791. Returns 
  1792.  
  1793. A pointer to the lexeme. 
  1794.  
  1795. Example 
  1796.  
  1797. char* zpchBuffer = zConsumer.lexemeBuffer();
  1798.  
  1799.  
  1800. ΓòÉΓòÉΓòÉ 6.2.6.10. lexemeLength ΓòÉΓòÉΓòÉ
  1801.  
  1802. The lexemeLength function returns the length of the current lexeme.  Usually, 
  1803. the only place you will use this function is in the SSLex::complete virtual 
  1804. function. If the SSLexMark instance is not passed, the length of the scanned 
  1805. data is returned. 
  1806.  
  1807. Signature 
  1808.  
  1809. SSUnsigned32 SSLexConsumer::lexemeLength( void);
  1810. SSUnsigned32 SSLexConsumer::lexemeLength( SSLexMark&);
  1811.  
  1812.  Parameters          Meaning 
  1813.  
  1814.  SSLexMark&          A reference to an SSLexMark. 
  1815.  
  1816.  Returns 
  1817.  
  1818.  The length of the lexeme. 
  1819.  
  1820.  Example 
  1821.  
  1822.   SSLexLexeme* SSLex::complete( SSLexConsumer& qConsumer
  1823.      SSLexFinalState& qFinal, SSLexMark& qMark)
  1824.      {
  1825.      SSUnsigned32 zulMark = qConsumer.lexemeLength( qMark);
  1826.      /* rest of function */
  1827.      }
  1828.  
  1829.  
  1830. ΓòÉΓòÉΓòÉ 6.2.6.11. lexemeToCurrent ΓòÉΓòÉΓòÉ
  1831.  
  1832. The lexemeToCurrent returns an instance of SSLexLexeme. 
  1833.  
  1834. This function is usually called in an SSLex error virtual function. 
  1835.  
  1836. Signature 
  1837.  
  1838. SSLexLexeme* SSLexLexeme::lexemeToCurrent( void);
  1839.  
  1840. Returns 
  1841.  
  1842. A pointer to the lexeme. 
  1843.  
  1844. Example 
  1845.  
  1846. This is the default complete virtual function. 
  1847.  
  1848. Example 
  1849.  
  1850. This is the default SSLex::error virtual function: 
  1851.  
  1852. SSLexLexeme* SSLex::error( SSLexConsumer& qConsumer)
  1853.    {
  1854.    SSLexLexeme* zpLexeme = qConsumer.lexemeToCurrent();
  1855.    throwException( SSExceptionLexError, SSLexMsgError, zpLexeme->.line(),
  1856.       zpLexeme->offset(), zpLexeme->asConstChar());
  1857.    return zpLexeme;
  1858.    }
  1859.  
  1860.  
  1861. ΓòÉΓòÉΓòÉ 6.2.6.12. lexemeToMark ΓòÉΓòÉΓòÉ
  1862.  
  1863. The lexemeToMark returns an instance of SSLexLexeme. 
  1864.  
  1865. This function is usually called in an SSLex complete virtual function. 
  1866.  
  1867. Signature 
  1868.  
  1869. SSLexLexeme* SSLexLexeme::lexemeToMark( SSLexMark&, SSUnsigned32);
  1870.  
  1871.  Parameters          Meaning 
  1872.  
  1873.  SSLexMark&          A reference to an SSLexMark. 
  1874.  
  1875.  SSUnsigned32        The token identifier associated with the lexeme. 
  1876.  
  1877.  Returns 
  1878.  
  1879.  A pointer to the lexeme. 
  1880.  
  1881.  Example 
  1882.  
  1883.  This is the default complete virtual function. 
  1884.  
  1885.   SSLexLexeme* SSLex::complete( SSLexConsumer& qConsumer
  1886.      SSUnsigned32 qulToken, SSLexMark& qMark)
  1887.      {
  1888.      return qConsumer.lexemeToMark( qMark, qulToken);
  1889.      }
  1890.  
  1891.  
  1892. ΓòÉΓòÉΓòÉ 6.2.6.13. line ΓòÉΓòÉΓòÉ
  1893.  
  1894. The line function returns the line number of the  beginning of the current 
  1895. lexeme (see currentBuffer). 
  1896.  
  1897. Signature 
  1898.  
  1899. SSUnsigned32 SSLexConsumer::line( void);
  1900.  
  1901. Returns 
  1902.  
  1903. The line number. 
  1904.  
  1905. Example 
  1906.  
  1907. SSUnsigned32 zulLine = zConsumer.line();
  1908.  
  1909.  
  1910. ΓòÉΓòÉΓòÉ 6.2.6.14. nextBuffer ΓòÉΓòÉΓòÉ
  1911.  
  1912. The nextBuffer pure virtual function is implemented by classes using 
  1913. SSLexConsumer as a base class.  This function is called when more data is 
  1914. needed for processing. 
  1915.  
  1916. Signature 
  1917.  
  1918. virtual SSUnsigned32 SSLexConsumer::nextBuffer( void) = 0;
  1919.  
  1920. Returns 
  1921.  
  1922. The length of the new data. 
  1923.  
  1924. Example 
  1925.  
  1926. This is similar to the SSLexFileConsumer implementation. opFile is a FILE*. 
  1927.  
  1928. SSUnsigned32 SSLexFileConsumer::nextBuffer( void)
  1929.    {
  1930.    SSUnsigned32 zulRead, zulFill;
  1931.    if ( shiftBuffer( zulRead, zulFill) && expandBuffer( zulRead, zulFill))
  1932.       return 0;
  1933.  
  1934.    return fread( buffer() + zulRead, 1, zulFill, opFile);
  1935.    }
  1936.  
  1937.  
  1938. ΓòÉΓòÉΓòÉ 6.2.6.15. offset ΓòÉΓòÉΓòÉ
  1939.  
  1940. The offset function returns the line offset of the  beginning of the current 
  1941. lexeme (see currentBuffer). 
  1942.  
  1943. Signature 
  1944.  
  1945. SSUnsigned32 SSLexConsumer::offset( void);
  1946.  
  1947. Returns 
  1948.  
  1949. The line offset. 
  1950.  
  1951. Example 
  1952.  
  1953. SSUnsigned32 zulOffset = zConsumer.offset();
  1954.  
  1955.  
  1956. ΓòÉΓòÉΓòÉ 6.2.6.16. setBuffer ΓòÉΓòÉΓòÉ
  1957.  
  1958. The setBuffer function sets the buffer pointer.  Typically, this function is 
  1959. used once in the constructor of a class derived from SSLexConsumer. 
  1960.  
  1961. Signature 
  1962.  
  1963. void SSLexConsumer::setBuffer( char*);
  1964.  
  1965.  Parameters          Meaning 
  1966.  
  1967.  char*               A buffer pointer. 
  1968.  
  1969.  Example 
  1970.  
  1971.  This example assumes you are running in a constructor of a class derived from 
  1972.  SSLexConsumer. 
  1973.  
  1974.   char* zpchBuffer = new char[ 4096];
  1975.   setBufferLength( 4096);
  1976.   setBuffer( zpchBuffer);
  1977.  
  1978.  
  1979. ΓòÉΓòÉΓòÉ 6.2.6.17. setBufferInc ΓòÉΓòÉΓòÉ
  1980.  
  1981. The setBufferInc function sets the buffer increment. The expandBuffer function 
  1982. is used to expand the buffer. 
  1983.  
  1984. Signature 
  1985.  
  1986. void SSLexConsumer::setBufferInc( SSUnsigned32);
  1987.  
  1988.  Parameters          Meaning 
  1989.  
  1990.  SSUnsigned32        The buffer increment. 
  1991.  
  1992.  Example 
  1993.  
  1994.  This example assumes you are running in a constructor of a class derived from 
  1995.  SSLexConsumer. 
  1996.  
  1997.   char* zpchBuffer = new char[ 4096];
  1998.   setBufferLength( 4096);
  1999.   setBuffer( zpchBuffer);
  2000.   setBufferInc( 4096);
  2001.  
  2002.  
  2003. ΓòÉΓòÉΓòÉ 6.2.6.18. setBufferLength ΓòÉΓòÉΓòÉ
  2004.  
  2005. The setBufferLength function sets the buffer length. 
  2006.  
  2007. Signature 
  2008.  
  2009. void SSLexConsumer::setBufferLength( SSUnsigned32);
  2010.  
  2011.  Parameters          Meaning 
  2012.  
  2013.  SSUnsigned32        The buffer length. 
  2014.  
  2015.  Example 
  2016.  
  2017.  This example assumes you are running in a constructor of a class derived from 
  2018.  SSLexConsumer. 
  2019.  
  2020.   char* zpchBuffer = new char[ 4096];
  2021.   setLength( 4096);
  2022.   setBuffer( zpchBuffer);
  2023.  
  2024.  
  2025. ΓòÉΓòÉΓòÉ 6.2.6.19. setBufferLength ΓòÉΓòÉΓòÉ
  2026.  
  2027. The setBufferLength function sets the initial data length. Normally, this 
  2028. function is used once in a constructor to set the initial data length. 
  2029.  
  2030. Signature 
  2031.  
  2032. void SSLexConsumer::setDataLength( SSUnsigned32);
  2033.  
  2034.  Parameters          Meaning 
  2035.  
  2036.  SSUnsigned32        The data length. 
  2037.  
  2038.  Example 
  2039.  
  2040.  This example assumes you are running in a constructor of a class derived from 
  2041.  SSLexConsumer. 
  2042.  
  2043.   char* zpchBuffer = new char[ 4096];
  2044.   setLength( 4096);
  2045.   setBuffer( zpchBuffer);
  2046.   strcpy( zpchBuffer, "Test Data");
  2047.   setDataLength( strlen( "Test Data"));
  2048.  
  2049.  
  2050. ΓòÉΓòÉΓòÉ 6.2.6.20. setEndOfData ΓòÉΓòÉΓòÉ
  2051.  
  2052. The setEndOfData function sets the end of data indicator.  The end of data 
  2053. indicator is also set when 0 is returned from nextBuffer. 
  2054.  
  2055. Signature 
  2056.  
  2057. void SSLexConsumer::setEndOfData( void);
  2058.  
  2059. Example 
  2060.  
  2061. zConsumer.setEndOfData();
  2062.  
  2063.  
  2064. ΓòÉΓòÉΓòÉ 6.2.6.21. shiftBuffer ΓòÉΓòÉΓòÉ
  2065.  
  2066. The shiftBuffer function shifts the data in the buffer. Unprocessed data at the 
  2067. end of the buffer is shifted over the processed data.  This will leave room at 
  2068. the end of the buffer for your nextBuffer function.  See also expandBuffer. 
  2069.  
  2070. Signature 
  2071.  
  2072. SSBooleanValue SSLexConsumer::shiftBuffer( SSUnsigned32&,
  2073.    SSUnsigned32&);
  2074.  
  2075.  Parameters          Meaning 
  2076.  
  2077.  SSUnsigned32&       A reference that is updated with the offset from the 
  2078.                      beginning of the buffer (see buffer) of the area to fill. 
  2079.  
  2080.  SSUnsigned32&       A reference that is updated with the length of the 
  2081.                      available area. 
  2082.  
  2083.  Returns 
  2084.  
  2085.  A success indicator.  SSFalse indicates data was shifted. 
  2086.  
  2087.  Example 
  2088.  
  2089.  The following example assumes you are running in a nextBuffer virtual 
  2090.  function. 
  2091.  
  2092.   SSUnsigned32 zulFill;
  2093.   SSUnsigned32 zulStart;
  2094.   SSBooleanValue zResult = shiftBuffer( zulStart, zulFill);
  2095.   if ( !zResult)
  2096.      {
  2097.      char* zpchStart = buffer() + zulStart;
  2098.      /* Read data into zpchBuffer with length zulFill */
  2099.      }
  2100.  
  2101.  
  2102. ΓòÉΓòÉΓòÉ 6.2.6.22. type ΓòÉΓòÉΓòÉ
  2103.  
  2104. The type function returns the consumer type. The consumer type is a nested enum 
  2105. SSLexConsumerType. Possible values are binary, character, or unicode. 
  2106.  
  2107. Signature 
  2108.  
  2109. SSLexConsumer::SSLexConsumerType SSLexConsumer::type( void);
  2110.  
  2111. Returns 
  2112.  
  2113. The consumer type. 
  2114.  
  2115. Example 
  2116.  
  2117. SSLexConsumer::SSLexConsumerType zType = qConsumer.type();
  2118.  
  2119.  
  2120. ΓòÉΓòÉΓòÉ 6.2.7. SSLexFileConsumer ΓòÉΓòÉΓòÉ
  2121.  
  2122.  Concepts 
  2123.  Constructors 
  2124.  
  2125.  
  2126. ΓòÉΓòÉΓòÉ 6.2.7.1. Concepts ΓòÉΓòÉΓòÉ
  2127.  
  2128. The SSLexFileConsumer class is used to construct file consumers for use by 
  2129. instances of SSLex.  See also SSLexStringConsumer. 
  2130.  
  2131.  
  2132. ΓòÉΓòÉΓòÉ 6.2.7.2. Constructors ΓòÉΓòÉΓòÉ
  2133.  
  2134. Signature 
  2135.  
  2136. SSLexFileConsumer::SSLexFileConsumer( const char*,
  2137.    SSLexConsumerType = character, SSUnsigned32 = SSLexConsumerDefaultSize,
  2138.    SSUnsigned32 = SSLexConsumerDefaultInc);
  2139.  
  2140.  const char*           A file name. 
  2141.  
  2142.  SSLexConsumerType     A consumer type.  See SSLexConsumer. 
  2143.  
  2144.  SSUnsigned32          The initial buffer length.  The default is the special 
  2145.                        length SSLexConsumerAll which allocates a buffer large 
  2146.                        enough for the entire file. 
  2147.  
  2148.  SSUnsigned32          The buffer increment.  The default increment is 0. 
  2149.  Example 
  2150.  
  2151.   SSLexFileConsumer zFile( "file.name");
  2152.  
  2153.  
  2154. ΓòÉΓòÉΓòÉ 6.2.8. SSLexStringConsumer ΓòÉΓòÉΓòÉ
  2155.  
  2156.  Concepts 
  2157.  Constructors 
  2158.  
  2159.  
  2160. ΓòÉΓòÉΓòÉ 6.2.8.1. Concepts ΓòÉΓòÉΓòÉ
  2161.  
  2162. The SSLexStringConsumer class is used to construct string consumers for use by 
  2163. instances of SSLex.  See also SSLexFileConsumer. 
  2164.  
  2165.  
  2166. ΓòÉΓòÉΓòÉ 6.2.8.2. Constructors ΓòÉΓòÉΓòÉ
  2167.  
  2168. Signature 
  2169.  
  2170. SSLexStringConsumer::SSLexStringConsumer( const char*,
  2171.    SSLexConsumerType = character);
  2172.  
  2173.  const char*           A string address. 
  2174.  
  2175.  SSLexConsumerType     A consumer type.  See SSLexConsumer. 
  2176.  
  2177.  Example 
  2178.  
  2179.   SSLexStringConsumer zFile( "This is a consumer string");
  2180.  
  2181.  
  2182. ΓòÉΓòÉΓòÉ 6.2.9. SSYacc ΓòÉΓòÉΓòÉ
  2183.  
  2184.  Concepts 
  2185.  Constructors 
  2186.  accept 
  2187.  elementFromProduction 
  2188.  elementFromStack 
  2189.  error 
  2190.  errorToken 
  2191.  lex 
  2192.  lookahead 
  2193.  nextLexeme 
  2194.  parse 
  2195.  pop 
  2196.  push 
  2197.  reduce 
  2198.  reset 
  2199.  setAbort 
  2200.  setLex 
  2201.  setTable 
  2202.  shift 
  2203.  shiftedSinceError 
  2204.  stackElement 
  2205.  validLookaheads 
  2206.  wasAborted 
  2207.  wasError 
  2208.  
  2209.  
  2210. ΓòÉΓòÉΓòÉ 6.2.9.1. Concepts ΓòÉΓòÉΓòÉ
  2211.  
  2212. The SSYacc class controls the parsing process. SSYacc is an abstract class with 
  2213. one pure virtual function, reduce. 
  2214.  
  2215. A skeleton reduce function is generated by Visual Parse++ in the header file 
  2216. ('.yh') for each rule file. 
  2217.  
  2218. An instance of SSYacc needs 2 pieces of data to function, a table and a lexer. 
  2219. Each of these is represented by a class. 
  2220.  
  2221. The table is the '.llr' file generated by Visual Parse++.  The associated class 
  2222. is SSYaccTable. This controls the parser. 
  2223.  
  2224. The lexer is an instance of SSLex. 
  2225.  
  2226.  
  2227. ΓòÉΓòÉΓòÉ 6.2.9.2. Constructors ΓòÉΓòÉΓòÉ
  2228.  
  2229. Signature 
  2230.  
  2231. SSYacc::SSYacc( const char* = 0);
  2232. SSYacc::SSYacc( SSLex&, const char*);
  2233. SSYacc::SSYacc( SSLex&, SSYaccTable&);
  2234.  
  2235. SSYacc instances are constructed in the following ways: 
  2236.  
  2237.   1. From a const char*.  In this case, you must supply the lexer with setLex 
  2238.      (and the table with setTable if the default is used). 
  2239.  
  2240.   2. From a reference to an SSLex and a table name. 
  2241.  
  2242.   3. From a previously constructed SSLex and SSYaccTable. 
  2243.  
  2244.  Example 
  2245.  
  2246.   SSLex       zLex( "file.name", "table.dfa");
  2247.   SSYaccTable zTable( "table.llr");
  2248.  
  2249.   SSYacc zYacc( "table.llr");
  2250.   zYacc.setLex( zLex);
  2251.  
  2252.   SSYacc zYacc( zLex, "table.llr");
  2253.  
  2254.   SSYacc zYacc( zLex, zTable);
  2255.  
  2256.  
  2257. ΓòÉΓòÉΓòÉ 6.2.9.3. accept ΓòÉΓòÉΓòÉ
  2258.  
  2259. The accept virtual function is called when parsing has completed.  The default 
  2260. function returns SSFalse if no errors occurred. 
  2261.  
  2262. The return value of this function is passed to the caller of parse. 
  2263.  
  2264. Signature 
  2265.  
  2266. virtual SSBooleanValue SSYacc::accept( void);
  2267.  
  2268. Returns 
  2269.  
  2270. An error indication.  SSFalse indicates no errors were encountered. 
  2271.  
  2272. Example 
  2273.  
  2274. This is the default accept function. 
  2275.  
  2276. SSBooleanValue SSYacc::accept( void)
  2277.    {
  2278.    return wasError();
  2279.    }
  2280.  
  2281.  
  2282. ΓòÉΓòÉΓòÉ 6.2.9.4. elementFromProduction ΓòÉΓòÉΓòÉ
  2283.  
  2284. The elementFromProduction function returns an element from the parse stack. 
  2285.  
  2286. The element returned is relative to the current production being reduced.  This 
  2287. is similar to the $1, $2, ..., variables in traditional yacc tools, except the 
  2288. index starts from 0. 
  2289.  
  2290. This function is only valid when called from the reduce virtual function. 
  2291.  
  2292. Signature 
  2293.  
  2294. SSYaccStackElement* SSYacc::elementFromProduction( SSSigned32);
  2295.  
  2296.  Parameters          Meaning 
  2297.  
  2298.  SSSigned32          The element index. Can be a negative number. 
  2299.  
  2300.  Returns 
  2301.  
  2302.  A pointer to the stack element associated with the index. 
  2303.  
  2304.  Example 
  2305.  
  2306.  The following example assumes you are in a case statement in a reduce virtual 
  2307.  function. 
  2308.  
  2309.   case AMyYaccProdSample:
  2310.      // Prod -> Symbol0 Symbol1 Symbol2
  2311.      {
  2312.      SSYaccStackElement* zpElement0 = elementFromProduction( 0);
  2313.      SSYaccStackElement* zpElement1 = elementFromProduction( 1);
  2314.      SSYaccStackElement* zpElement2 = elementFromProduction( 2);
  2315.      }
  2316.  
  2317.  
  2318. ΓòÉΓòÉΓòÉ 6.2.9.5. elementFromStack ΓòÉΓòÉΓòÉ
  2319.  
  2320. The elementFromStack function returns an element from the parse stack. 
  2321.  
  2322. The element returned is relative to the top of the parsing stack. Zero is the 
  2323. top of the stack. 
  2324.  
  2325. Signature 
  2326.  
  2327. SSYaccStackElement* SSYacc::elementFromStack( SSUnsigned32);
  2328.  
  2329.  Parameters          Meaning 
  2330.  
  2331.  SSUnsigned32        The element index. 
  2332.  
  2333.  Returns 
  2334.  
  2335.  A pointer to the stack element associated with the index. 
  2336.  
  2337.  
  2338. ΓòÉΓòÉΓòÉ 6.2.9.6. error ΓòÉΓòÉΓòÉ
  2339.  
  2340. The error virtual function is called when a parsing error occurs.  The default 
  2341. function calls errorToken to resolve the error. 
  2342.  
  2343. Signature 
  2344.  
  2345. virtual SSBooleanValue SSYacc::error( SSUnsigned32,
  2346.    SSLexLexeme&);
  2347.  
  2348.  Parameters          Meaning 
  2349.  
  2350.  SSUnsigned32        The state number. 
  2351.  
  2352.  SSLexLexeme&        The lookahead lexeme. 
  2353.  
  2354.  Returns 
  2355.  
  2356.  A continuation indication.  SSFalse means keep processing, SSTrue to exit the 
  2357.  parsing process. 
  2358.  
  2359.  Example 
  2360.  
  2361.  This is the default error function. 
  2362.  
  2363.   SSBooleanValue SSYacc::error( SSUnsigned32 qulState,
  2364.      SSLexLexeme& qLookahead)
  2365.      {
  2366.      return errorToken();
  2367.      }
  2368.  
  2369.  
  2370. ΓòÉΓòÉΓòÉ 6.2.9.7. errorToken ΓòÉΓòÉΓòÉ
  2371.  
  2372. The errorToken function performs error recovery.  Error recovery is described 
  2373. in Error Recovery. 
  2374.  
  2375. Signature 
  2376.  
  2377. SSBooleanValue SSYacc::errorToken( void);
  2378.  
  2379. Returns 
  2380.  
  2381. Throws an SSException if recovery fails. 
  2382.  
  2383. Example 
  2384.  
  2385. This is the default error function. 
  2386.  
  2387. SSBooleanValue SSYacc::error( SSUnsigned32 qulState,
  2388.    SSLexLexeme& qLookahead)
  2389.    {
  2390.    return errorToken();
  2391.    }
  2392.  
  2393.  
  2394. ΓòÉΓòÉΓòÉ 6.2.9.8. lex ΓòÉΓòÉΓòÉ
  2395.  
  2396. The lex function returns a pointer to the SSLex instance. 
  2397.  
  2398. Signature 
  2399.  
  2400. SSLex* SSYacc::lex( void);
  2401.  
  2402. Returns 
  2403.  
  2404. A pointer to the SSLex instance or 0. 
  2405.  
  2406. Example 
  2407.  
  2408. SSLex zLex( "file.name", "table.dfa");
  2409. SSYacc zYacc( zLex, "table.llr");
  2410.  
  2411. SSLex* zpLex = zYacc.lex();
  2412.  
  2413.  
  2414. ΓòÉΓòÉΓòÉ 6.2.9.9. lookahead ΓòÉΓòÉΓòÉ
  2415.  
  2416. The lookahead function returns the current lookahead lexeme. 
  2417.  
  2418. Signature 
  2419.  
  2420. SSLexLexeme& SSYacc::lookahead( void);
  2421.  
  2422. Returns 
  2423.  
  2424. The current lookahead lexeme. 
  2425.  
  2426. Example 
  2427.  
  2428. SSLex zLex( "file.name", "table.dfa");
  2429. SSYacc zYacc( zLex, "table.llr");
  2430.  
  2431. SSLexLexeme& zLexeme = zYacc.lookahead();
  2432.  
  2433.  
  2434. ΓòÉΓòÉΓòÉ 6.2.9.10. nextLexeme ΓòÉΓòÉΓòÉ
  2435.  
  2436. The nextLexeme virtual function returns the next lexeme. Override this function 
  2437. if you want to supply lexemes from a source other than an SSLex instance. 
  2438.  
  2439. Signature 
  2440.  
  2441. virtual SSLexLexeme* SSYacc::nextLexeme( void);
  2442.  
  2443. Returns 
  2444.  
  2445. The next lexeme.  0 indicates end of data. 
  2446.  
  2447. Example 
  2448.  
  2449. This is the default nextLexeme function. 
  2450.  
  2451. SSLexLexeme* SSYacc::nextLexeme( void)
  2452.    {
  2453.    return ( *lex())++;
  2454.    }
  2455.  
  2456.  
  2457. ΓòÉΓòÉΓòÉ 6.2.9.11. parse ΓòÉΓòÉΓòÉ
  2458.  
  2459. The parse function starts the parsing process. 
  2460.  
  2461. Signature 
  2462.  
  2463. SSBooleanValue SSYacc::parse( void);
  2464.  
  2465. Returns 
  2466.  
  2467. An error indication.  SSTrue indicates an error occurred. Can also throw an 
  2468. SSException. 
  2469.  
  2470. Example 
  2471.  
  2472. SSLex  zLex( "file.name", "table.dfa");
  2473. SSYacc zYacc( zLex, "table.llr");
  2474.  
  2475. zYacc.parse();
  2476.  
  2477.  
  2478. ΓòÉΓòÉΓòÉ 6.2.9.12. pop ΓòÉΓòÉΓòÉ
  2479.  
  2480. The pop function pops elements off the parsing stack. Extreme caution should be 
  2481. used when using this function. It is only intended to be used for customized 
  2482. error recovery. You must have extensive knowledge of LR parsing theory to use 
  2483. this function. 
  2484.  
  2485. Signature 
  2486.  
  2487. SSBooleanValue SSYacc::pop( SSUnsigned32);
  2488.  
  2489.  Parameters          Meaning 
  2490.  
  2491.  SSUnsigned32        The stack offset. Zero represents the top of the stack. 
  2492.  
  2493.  Returns 
  2494.  
  2495.  Throws an instance of SSException if an error occurs. 
  2496.  
  2497.  
  2498. ΓòÉΓòÉΓòÉ 6.2.9.13. push ΓòÉΓòÉΓòÉ
  2499.  
  2500. The push function pushes an element on the parsing stack. Extreme caution 
  2501. should be used when using this function. It is only intended to be used for 
  2502. customized error recovery. You must have extensive knowledge of LR parsing 
  2503. theory to use this function. 
  2504.  
  2505. Signature 
  2506.  
  2507. SSBooleanValue SSYacc::push( SSYaccStackElement&);
  2508.  
  2509.  Parameters          Meaning 
  2510.  
  2511.  SSYaccStackElement  A stack element. 
  2512.  
  2513.  Returns 
  2514.  
  2515.  Throws an instance of SSException if an error occurs. 
  2516.  
  2517.  
  2518. ΓòÉΓòÉΓòÉ 6.2.9.14. reduce ΓòÉΓòÉΓòÉ
  2519.  
  2520. The reduce pure virtual function is called when a reduction occurrs.  Visual 
  2521. Parse++ generates a skeleton reduce function for each rule file. 
  2522.  
  2523. Classes derived from SSYacc must supply a reduce function. 
  2524.  
  2525. Signature 
  2526.  
  2527. SSYaccStackElement* SSYacc::reduce( SSUnsigned32, SSUnsigned32);
  2528.  
  2529.  Parameters          Meaning 
  2530.  
  2531.  SSUnsigned32        The production number. 
  2532.  
  2533.  SSUnsigned32        The production size. 
  2534.  
  2535.  Returns 
  2536.  
  2537.  A stack element.  This is pushed on top of the stack after the right hand side 
  2538.  of the production is popped.  0 will terminate the parsing process. 
  2539.  
  2540.  Example 
  2541.  
  2542.   SSLex  zLex( "file.name", "table.dfa");
  2543.   SSYacc zYacc( zLex, "table.llr");
  2544.   zYacc.parse();
  2545.     ┬╖
  2546.     ┬╖
  2547.   SSYaccStackElement* MyYaccClass::reduce( SSUnsigned32 qProd,
  2548.      SSUnsigned32 qSize);
  2549.      {
  2550.      switch( qProd)
  2551.        {
  2552.        case MyYaccProduction0:
  2553.        // Prod -> ...
  2554.  
  2555.        case MyYaccProduction1:
  2556.        // Prod -> ...
  2557.  
  2558.        case MyYaccProduction2:
  2559.        // Prod -> ...
  2560.  
  2561.        ┬╖
  2562.        ┬╖
  2563.        ┬╖
  2564.        default:
  2565.           break;
  2566.        }
  2567.  
  2568.      return stackElement();
  2569.      }
  2570.  
  2571.  
  2572. ΓòÉΓòÉΓòÉ 6.2.9.15. reset ΓòÉΓòÉΓòÉ
  2573.  
  2574. The reset function resets the parser to its initial state. This function is 
  2575. provided to reuse a parser (after a parse  has been issued) without deleting 
  2576. and reconstructing the parser. 
  2577.  
  2578. Signature 
  2579.  
  2580. void SSYacc::reset( void);
  2581.  
  2582. Example 
  2583.  
  2584. zYacc.reset();
  2585.  
  2586.  
  2587. ΓòÉΓòÉΓòÉ 6.2.9.16. setAbort ΓòÉΓòÉΓòÉ
  2588.  
  2589. The setAbort function aborts the parsing process. 
  2590.  
  2591. Signature 
  2592.  
  2593. void SSYacc::setAbort( void);
  2594.  
  2595. Example 
  2596.  
  2597. This example assumes you are running in an SSYacc virtual function. 
  2598.  
  2599. setAbort();
  2600.  
  2601.  
  2602. ΓòÉΓòÉΓòÉ 6.2.9.17. setLex ΓòÉΓòÉΓòÉ
  2603.  
  2604. The setLex function sets the lexer for the SSYacc instance. 
  2605.  
  2606. Signature 
  2607.  
  2608. void SSYacc::setLex( SSLex&);
  2609.  
  2610.  Parameters          Meaning 
  2611.  
  2612.  SSLex&              An SSLex instance. 
  2613.  
  2614.  Example 
  2615.  
  2616.   SSLex  zLex( "file.name", "table.dfa");
  2617.   SSYacc zYacc( "table.llr");
  2618.   zYacc.setLex( zLex);
  2619.  
  2620.  
  2621. ΓòÉΓòÉΓòÉ 6.2.9.18. setTable ΓòÉΓòÉΓòÉ
  2622.  
  2623. The setTable function sets the table for the SSYacc instance. 
  2624.  
  2625. Signature 
  2626.  
  2627. void SSYacc::setTable( const char*);
  2628. void SSYacc::setTable( SSYaccTable&);
  2629.  
  2630.  Parameters          Meaning 
  2631.  
  2632.  const char*         A table name. 
  2633.  
  2634.  SSYaccTable&        An SSYaccTable instance. 
  2635.  
  2636.  Example 
  2637.  
  2638.   SSLex  zLex( "file.name", "table.dfa");
  2639.   SSYacc zYacc;
  2640.   zYacc.setLex( zLex);
  2641.   zYacc.setTable( "table.llr");
  2642.  
  2643.  
  2644. ΓòÉΓòÉΓòÉ 6.2.9.19. shift ΓòÉΓòÉΓòÉ
  2645.  
  2646. The shift virtual function is called each time a token is shifted. 
  2647.  
  2648. Signature 
  2649.  
  2650. virtual SSYaccStackElement* SSYacc::shift( SSLexLexeme&);
  2651.  
  2652.  Parameters          Meaning 
  2653.  
  2654.  SSLexLexeme&        The lexeme about to be shifted. 
  2655.  
  2656.  Returns 
  2657.  
  2658.  A stack element that is pushed on the stack.  0 will terminate the parsing 
  2659.  process. 
  2660.  
  2661.  Example 
  2662.  
  2663.  This is the default shift virtual function. 
  2664.  
  2665.   SSYaccStackElement* SSYacc::shift( SSLexLexeme& qLexeme)
  2666.      {
  2667.      return stackElement();
  2668.      }
  2669.  
  2670.  
  2671. ΓòÉΓòÉΓòÉ 6.2.9.20. shiftedSinceError ΓòÉΓòÉΓòÉ
  2672.  
  2673. The shiftedSinceError function returns the number of tokens shifted since the 
  2674. last error. 
  2675.  
  2676. Signature 
  2677.  
  2678. SSUnsigned32 SSYacc::shiftedSinceError( void);
  2679.  
  2680. Returns 
  2681.  
  2682. A number of tokens shifted since the last error. 
  2683.  
  2684. Example 
  2685.  
  2686. This example assumes you are in an SSYacc virtual function. 
  2687.  
  2688. SSUnsigned32 zulError = shiftedSinceError();
  2689.  
  2690.  
  2691. ΓòÉΓòÉΓòÉ 6.2.9.21. stackElement ΓòÉΓòÉΓòÉ
  2692.  
  2693. The stackElement virtual function is called each time a stack element is 
  2694. needed.  The default function returns an SSYaccStackElement.  Override this 
  2695. function if you want to use customized stack elements derived from 
  2696. SSYaccStackElement. 
  2697.  
  2698. Signature 
  2699.  
  2700. virtual SSYaccStackElement* SSYacc::stackElement( void);
  2701.  
  2702. Returns 
  2703.  
  2704. A stack element. 0 terminates the parsing process. 
  2705.  
  2706. Example 
  2707.  
  2708. This is the default stackElement virtual function. The refDec function is used 
  2709. to set the use count to 0 before returning.  See Reference Counting and refDec 
  2710. for more information. 
  2711.  
  2712. SSYaccStackElement* SSYacc::stackElement( void)
  2713.    {
  2714.    SSYaccStackElement* zpElement = new SSYaccStackElement;
  2715.    zpElement->refDec( SSFalse);
  2716.    return zpElement;
  2717.    }
  2718.  
  2719.  
  2720. ΓòÉΓòÉΓòÉ 6.2.9.22. validLookaheads ΓòÉΓòÉΓòÉ
  2721.  
  2722. The validLookaheads function returns an array of tokens containing the valid 
  2723. lookaheads for the given state.  You must delete the array returned (delete 
  2724. []).  See also SSLex::tokenToConstChar. 
  2725.  
  2726. Signature 
  2727.  
  2728. SSUnsigned32* SSYacc::validLookaheads( SSUnsigned32,
  2729.    SSUnsigned32&);
  2730.  
  2731.  Parameters          Meaning 
  2732.  
  2733.  SSUnsigned32        The state. 
  2734.  
  2735.  SSUnsigned32&       A reference that will be updated with the number of tokens 
  2736.                      in the array. 
  2737.  
  2738.  Returns 
  2739.  
  2740.  An array containing the lookahead tokens. 
  2741.  
  2742.  Example 
  2743.  
  2744.   SSLex         zLex( "file.name", "table.dfa");
  2745.   SSYacc        zYacc( zLex, "table.llr");
  2746.   SSUnsigned32  zulCount;
  2747.   SSUnsigned32* zpTokens = validLookaheads( zulState, zulCount);
  2748.  
  2749.   string zMsg( "Expected ");
  2750.   zMsg.concatenate( zLex.tokenToConstChar( zpTokens[ 0]));
  2751.   for ( int i = 1; i < zulCount; i++)
  2752.       {
  2753.       zMsg.concatenate( ", ");
  2754.       zMsg.concatenate( zLex.tokenToConstChar( zpTokens[ i]));
  2755.       }
  2756.  
  2757.   delete [] zpTokens;
  2758.  
  2759.  
  2760. ΓòÉΓòÉΓòÉ 6.2.9.23. wasAborted ΓòÉΓòÉΓòÉ
  2761.  
  2762. The wasAborted function is used to determine if the parsing process was aborted 
  2763. with setAbort. 
  2764.  
  2765. Signature 
  2766.  
  2767. SSBooleanValue SSYacc::wasAborted( void);
  2768.  
  2769. Returns 
  2770.  
  2771. SSTrue if setAbort was used to abort the parsing process. 
  2772.  
  2773. Example 
  2774.  
  2775. SSLex zLex( "file.name", "table.dfa");
  2776. SSYacc zYacc( zLex, "table.llr");
  2777. zYacc.parse();
  2778. if ( zYacc.wasAborted())
  2779.    {
  2780.    /* Aborted */
  2781.    }
  2782.  
  2783.  
  2784. ΓòÉΓòÉΓòÉ 6.2.9.24. wasError ΓòÉΓòÉΓòÉ
  2785.  
  2786. The wasError function is used to determine if an error occurred while parsing. 
  2787.  
  2788. Signature 
  2789.  
  2790. SSBooleanValue SSYacc::wasError( void);
  2791.  
  2792. Returns 
  2793.  
  2794. SSTrue if an error occurred. 
  2795.  
  2796. Example 
  2797.  
  2798. SSLex zLex( "file.name", "table.dfa");
  2799. SSYacc zYacc( zLex, "table.llr");
  2800. zYacc.parse();
  2801. if ( zYacc.wasError())
  2802.    {
  2803.    /* Error occurred */
  2804.    }
  2805.  
  2806.  
  2807. ΓòÉΓòÉΓòÉ 6.2.10. SSYaccTable ΓòÉΓòÉΓòÉ
  2808.  
  2809.  Concepts 
  2810.  Constructors 
  2811.  
  2812.  
  2813. ΓòÉΓòÉΓòÉ 6.2.10.1. Concepts ΓòÉΓòÉΓòÉ
  2814.  
  2815. The SSYaccTable class represents a parsing table. 
  2816.  
  2817. Tables can be shared.  The main use of SSYaccTable is to define static 
  2818. definitions of frequently used tables so the file will only be read once, when 
  2819. the SSYaccTable instance is constructed. 
  2820.  
  2821.  
  2822. ΓòÉΓòÉΓòÉ 6.2.10.2. Constructors ΓòÉΓòÉΓòÉ
  2823.  
  2824. Signature 
  2825.  
  2826. SSYaccTable::SSYaccTable( const char*);
  2827.  
  2828. SSYaccTable instances are constructed out of a file name. 
  2829.  
  2830. Example 
  2831.  
  2832. SSYaccTable zTable( "table.llr");
  2833.  
  2834.  
  2835. ΓòÉΓòÉΓòÉ 6.2.11. SSYaccStackElement ΓòÉΓòÉΓòÉ
  2836.  
  2837.  Concepts 
  2838.  Constructors 
  2839.  lexeme 
  2840.  state 
  2841.  
  2842.  
  2843. ΓòÉΓòÉΓòÉ 6.2.11.1. Concepts ΓòÉΓòÉΓòÉ
  2844.  
  2845. Items put on the parsing stack are made out of the SSYaccStackElement class. 
  2846. SSYaccStackElements contain a field for a lexeme and state information.  If you 
  2847. need extra information in a stack element, derive a class from 
  2848. SSYaccStackElement and override the SSYacc member function stackElement. 
  2849.  
  2850. SSYaccStackElements can be accessed with the SSYacc member function 
  2851. elementFromProduction. 
  2852.  
  2853. Note: You must implement the refFree virtual function if you derive a class 
  2854. from SSYaccStackElement.  Reference counting is used to control the lifetime of 
  2855. SSYaccStackElements.  See SSRefCount and Reference Counting for more 
  2856. information. 
  2857.  
  2858.  
  2859. ΓòÉΓòÉΓòÉ 6.2.11.2. Constructors ΓòÉΓòÉΓòÉ
  2860.  
  2861. Signature 
  2862.  
  2863. SSYaccStackElement::SSYaccStackElement( void);
  2864.  
  2865. The constructor accepts no parameters. 
  2866.  
  2867. Example 
  2868.  
  2869. SSYaccStackElement zElement;
  2870.  
  2871.  
  2872. ΓòÉΓòÉΓòÉ 6.2.11.3. lexeme ΓòÉΓòÉΓòÉ
  2873.  
  2874. The lexeme function returns the lexeme associated with the stack element. 
  2875.  
  2876. Signature 
  2877.  
  2878. SSLexLexeme* YaccStackElement::lexeme( void);
  2879.  
  2880. Returns 
  2881.  
  2882. The lexeme pointer or 0. 
  2883.  
  2884. Example 
  2885.  
  2886. The following example assumes you are in a case statement in a reduce virtual 
  2887. function. 
  2888.  
  2889. case AMyYaccProdSample:
  2890.    // Prod -> Symbol0 Symbol1 Symbol2
  2891.    {
  2892.    SSYaccStackElement* zpElement0 = elementFromProduction( 0);
  2893.    SSLexLexeme* zpLexeme = zpElement0->lexeme();
  2894.    }
  2895.  
  2896.  
  2897. ΓòÉΓòÉΓòÉ 6.2.11.4. state ΓòÉΓòÉΓòÉ
  2898.  
  2899. The state function returns the state associated with the stack element. 
  2900.  
  2901. Signature 
  2902.  
  2903. SSUnsigned32 YaccStackElement::lexeme( void);
  2904.  
  2905. Returns 
  2906.  
  2907. The state number. 
  2908.  
  2909. Example 
  2910.  
  2911. The following example assumes you are in a case statement in a reduce virtual 
  2912. function. 
  2913.  
  2914. case AMyYaccProdSample:
  2915.    // Prod -> Symbol0 Symbol1 Symbol2
  2916.    {
  2917.    SSYaccStackElement* zpElement0 = elementFromProduction( 0);
  2918.    SSUnsigned32 zulState = zpElement0->state();
  2919.    }
  2920.  
  2921.  
  2922. ΓòÉΓòÉΓòÉ 6.2.12. SSException ΓòÉΓòÉΓòÉ
  2923.  
  2924.  Concepts 
  2925.  Constructors 
  2926.  errorId 
  2927.  setText 
  2928.  text 
  2929.  
  2930.  
  2931. ΓòÉΓòÉΓòÉ 6.2.12.1. Concepts ΓòÉΓòÉΓòÉ
  2932.  
  2933. Visual Parse++ classes throw objects of this class when errors occur. 
  2934.  
  2935.  
  2936. ΓòÉΓòÉΓòÉ 6.2.12.2. Constructors ΓòÉΓòÉΓòÉ
  2937.  
  2938. Signature 
  2939.  
  2940. SSException::SSException( const char*, SSUnsigned32 = 0);
  2941. SSException::SSException( const SSException&);
  2942.  
  2943. SSException objects can be constructed in one of the following ways: 
  2944.  
  2945.   1. From a const char* containing a message and an error id that defaults to 
  2946.      0. 
  2947.  
  2948.   2. From another SSException. 
  2949.  
  2950.  Example 
  2951.  
  2952.   SSException zExcept( "Error message", 100);
  2953.  
  2954.  
  2955. ΓòÉΓòÉΓòÉ 6.2.12.3. errorId ΓòÉΓòÉΓòÉ
  2956.  
  2957. The errorId function returns the error id.  Possible error ids are listed in 
  2958. ssexcept.h. 
  2959.  
  2960. Signature 
  2961.  
  2962. SSUnsigned32 SSException::errorId( void);
  2963.  
  2964. Returns 
  2965.  
  2966. The error id. 
  2967.  
  2968. Example 
  2969.  
  2970. try
  2971.    {
  2972.    SSLex zLex( "file.name", "table.dfa");
  2973.    SSYacc zYacc( zLex, "table.llr");
  2974.    zYacc.parse();
  2975.    }
  2976. catch ( SSException zExcept)
  2977.    {
  2978.    SSUnsigned32 zulError = zExcept.errorId();
  2979.    }
  2980.  
  2981.  
  2982. ΓòÉΓòÉΓòÉ 6.2.12.4. setText ΓòÉΓòÉΓòÉ
  2983.  
  2984. The setText function sets the text associated with the SSException object.  The 
  2985. length is truncated to SSExceptionTextLength, defined in ssexcept.hpp. 
  2986.  
  2987. Signature 
  2988.  
  2989. void SSException::setText( const char*);
  2990.  
  2991.  Parameters          Meaning 
  2992.  
  2993.  const char*         The text. 
  2994.  
  2995.  Example 
  2996.  
  2997.   SSException zpExcept = new SSException( "");
  2998.   zpExcept->setText( "New message text");
  2999.  
  3000.  
  3001. ΓòÉΓòÉΓòÉ 6.2.12.5. text ΓòÉΓòÉΓòÉ
  3002.  
  3003. The text function returns the text. 
  3004.  
  3005. Signature 
  3006.  
  3007. const char* SSException::text( void);
  3008.  
  3009. Returns 
  3010.  
  3011. The text. 
  3012.  
  3013. Example 
  3014.  
  3015. try
  3016.    {
  3017.    SSLex zLex( "file.name", "table.dfa");
  3018.    SSYacc zYacc( zLex, "table.llr");
  3019.    zYacc.parse();
  3020.    }
  3021. catch ( SSException zExcept)
  3022.    {
  3023.    cout << zExcept.text();
  3024.    }
  3025.  
  3026.  
  3027. ΓòÉΓòÉΓòÉ 6.2.13. Reference Counting ΓòÉΓòÉΓòÉ
  3028.  
  3029. Because of the proliferation and sharing of some objects, the lifetime of the 
  3030. object instances is indeterminate to the component creating the objects. The 
  3031. question "When do I delete the object instance ?" cannot be answered when the 
  3032. object is created. Two or more completely seperate components have access to 
  3033. the object, so how do I control object cleanup ? 
  3034.  
  3035. One answer is to use a reference counting scheme.  Each component increments a 
  3036. reference count when accessing the shared object.  While the reference count is 
  3037. non-zero, the object is in use by some component. When processing has been 
  3038. completed, the reference count is decremented. If and only if it is 0, the 
  3039. object is deleted. 
  3040.  
  3041. The classes SSRef and SSRefCount implement reference counting.  SSRef is a 
  3042. template class.  The template argument is a class derived from SSRefCount. 
  3043.  
  3044. Instances of the template class SSRef control the reference count contained in 
  3045. the SSRefCount class.  It acts as a smart pointer.  You use the SSRef class 
  3046. exactly as you would use a pointer. 
  3047.  
  3048. When an SSRef instance is assigned a pointer or reference, the reference count 
  3049. is incremented (refInc). When the SSRef instance is destroyed or reassigned, 
  3050. the reference count is decremented (refDec). If it is 0, the virtual member 
  3051. function refFree is called to delete the object associated with the reference. 
  3052.  
  3053. The classes SSLexLexeme and SSYaccStackElement are derived from SSRefCount 
  3054. since they are shared between your application code and the SSLex and SSYacc 
  3055. classes. To ensure integrity, you should use the SSLexLexemeRef and 
  3056. SSYaccStackElementRef classes to control access to these objects. 
  3057.  
  3058. An example should help clarify some of these points.  The main virtual function 
  3059. of interest to your application is the reduce member function in the SSYacc 
  3060. class.  The reduce function is called each time a production is reduced.  This 
  3061. is the driver for your parser, where all the activity occurs. 
  3062.  
  3063. In this function,  you have access to SSLexLexemes and SSYaccStackElements. A 
  3064. common requirement would be to use these objects in your application code 
  3065. during the parsing process.  All you need to do is use the SSLexLexemeRef and 
  3066. SSYaccStackElementRef classes to refer to these objects and cleanup is 
  3067. automatic. 
  3068.  
  3069. Examine the following code: 
  3070.  
  3071. class MySymbolClass : public SomeListElementClass
  3072.    {
  3073.    public:
  3074.                      MySymbolClass( SSLexLexeme*);
  3075.    SSLexLexeme*      lexeme( void);
  3076.  
  3077.    private:
  3078.       SSLexLexemeRef orLexeme;
  3079.    };
  3080.  
  3081. MySymbolClass::MySymbolClass( SSLexLexeme* qpLexeme) : orLexeme( qpLexeme)
  3082.    {
  3083.    }
  3084.  
  3085. SSLexLexeme* MySymbolClass::lexeme( void)
  3086.    {
  3087.    return orLexeme;
  3088.    }
  3089.  
  3090. class MyYaccClass : public SSYacc
  3091.    {
  3092.    public:
  3093.       ┬╖
  3094.       ┬╖
  3095.    private:
  3096.       SomeListClass oList;
  3097.    };
  3098.  
  3099. SSYaccStackElement* MyYaccClass::reduce( SSUnsigned32 qulProd,
  3100.    SSUnsigned32 qulSize)
  3101.    {
  3102.    switch ( qulProd)
  3103.       {
  3104.       case MyYaccProd0:
  3105.       // Prod -> Symbol0
  3106.          {
  3107.          SSYaccStackElement* zpElement0 = elementFromProduction( 0);
  3108.          MySymbolClass* zpMySymbol = new MySymbolClass( zpElement0->lexeme());
  3109.          oList.add( zpMySymbol);
  3110.  
  3111.       ┬╖
  3112.       ┬╖
  3113.       }
  3114.    return stackElement();
  3115.    }
  3116.  
  3117. The intention is to keep a list (SomeListClass) of a new class, MySymbolClass, 
  3118. which contains lexeme objects. I embed the SSLexLexemeRef in the new class to 
  3119. ensure that the lexeme is not deleted. The reference causes the use count to be 
  3120. incremented, extending the lifetime of the object.  The lexeme will not be 
  3121. deleted until the MySymbolClass instance is deleted. 
  3122.  
  3123.  
  3124. ΓòÉΓòÉΓòÉ 6.2.14. SSRef ΓòÉΓòÉΓòÉ
  3125.  
  3126.  Concepts 
  3127.  Constructors 
  3128.  operator= 
  3129.  operator* 
  3130.  operator-> 
  3131.  operator T* 
  3132.  
  3133.  
  3134. ΓòÉΓòÉΓòÉ 6.2.14.1. Concepts ΓòÉΓòÉΓòÉ
  3135.  
  3136. The SSRef class is essentially a smart pointer template class. The template 
  3137. argument is a class derived from SSRefCount. See Reference Counting for a 
  3138. complete discussion. 
  3139.  
  3140.  
  3141. ΓòÉΓòÉΓòÉ 6.2.14.2. Constructors ΓòÉΓòÉΓòÉ
  3142.  
  3143. The constructors assume a template argument T. 
  3144.  
  3145. Signature 
  3146.  
  3147. SSRef::SSRef( T*);
  3148. SSRef::SSRef( T&);
  3149. SSRef::SSRef( void);
  3150. SSRef::SSRef( SSRef< T>&);
  3151.  
  3152. You can construct an SSRef in one of the following ways: 
  3153.  
  3154.   1. From a pointer to a T. 
  3155.  
  3156.   2. From a reference to a T. 
  3157.  
  3158.   3. With no parameters. 
  3159.  
  3160.   4. From another SSRef< T>. 
  3161.  
  3162.  Example 
  3163.  
  3164.  Assume you are passed a C++ reference to a SSLexLexeme object in qLexeme. 
  3165.  
  3166.   typedef SSRef< SSLexLexeme> SSLexLexemeRef;
  3167.  
  3168.   SSLexLexemeRef zpLexeme0( &qLexeme);
  3169.   SSLexLexemeRef zpLexeme1( qLexeme);
  3170.  
  3171.  
  3172. ΓòÉΓòÉΓòÉ 6.2.14.3. operator= ΓòÉΓòÉΓòÉ
  3173.  
  3174. The overloaded assignment operator accepts 3 types, a pointer, a C++ reference, 
  3175. or a reference to another SSRef. 
  3176.  
  3177. Signature 
  3178.  
  3179. SSRef< T>& SSRef::operator=( T*);
  3180. SSRef< T>& SSRef::operator=( T&);
  3181. SSRef< T>& SSRef::operator=( SSRef< T>&);
  3182.  
  3183. Returns 
  3184.  
  3185. The SSRef object. 
  3186.  
  3187. Example 
  3188.  
  3189. Assume you are passed a C++ reference to a SSLexLexeme object in qLexeme. 
  3190.  
  3191. typedef SSRef< SSLexLexeme> SSLexLexemeRef;
  3192.  
  3193. SSLexLexemeRef zRef0;
  3194. SSLexLexemeRef zRef1;
  3195. zRef0 = &qLexeme;
  3196. zRef1 = qLexeme;
  3197.  
  3198.  
  3199. ΓòÉΓòÉΓòÉ 6.2.14.4. operator* ΓòÉΓòÉΓòÉ
  3200.  
  3201. The dereference operator returns a reference to the underlying template 
  3202. argument object instance. 
  3203.  
  3204. Signature 
  3205.  
  3206. SSRef::operator*( void);
  3207.  
  3208. Returns 
  3209.  
  3210. The SSRef template argument object instance. 
  3211.  
  3212. Example 
  3213.  
  3214. Assume you are passed a C++ reference to a SSLexLexeme object in qLexeme. 
  3215.  
  3216. typedef SSRef< SSLexLexeme> SSLexLexemeRef;
  3217.  
  3218. SSLexLexemeRef zRef( qLexeme);
  3219. SSLexLexeme&   zLexeme( *zRef);
  3220.  
  3221.  
  3222. ΓòÉΓòÉΓòÉ 6.2.14.5. operator-> ΓòÉΓòÉΓòÉ
  3223.  
  3224. This overloaded operator accesses members of the underlying template argument 
  3225. object instance. 
  3226.  
  3227. Signature 
  3228.  
  3229. T* SSRef::operator->( void);
  3230.  
  3231. Returns 
  3232.  
  3233. A pointer to the template argument object instance. 
  3234.  
  3235. Example 
  3236.  
  3237. Assume you are passed a C++ reference to a SSLexLexeme object in qLexeme. 
  3238.  
  3239. typedef SSRef< SSLexLexeme> SSLexLexemeRef;
  3240.  
  3241. SSLexLexemeRef zRef( qLexeme);
  3242. SSUnsigned32 zulToken = zRef->token();
  3243.  
  3244.  
  3245. ΓòÉΓòÉΓòÉ 6.2.14.6. operator T* ΓòÉΓòÉΓòÉ
  3246.  
  3247. The T* conversion operator.  Converts an SSRef< T> to a T*. 
  3248.  
  3249. Signature 
  3250.  
  3251. SSRef::operator T*( void);
  3252.  
  3253. Returns 
  3254.  
  3255. A pointer to the template argument object instance. 
  3256.  
  3257. Example 
  3258.  
  3259. Assume you are passed a C++ reference to a SSLexLexeme object in qLexeme. 
  3260.  
  3261. typedef SSRef< SSLexLexeme> SSLexLexemeRef;
  3262.  
  3263. SSLexLexemeRef zRef( qLexeme);
  3264. SSLexLexeme*   zpLexeme = zRef;
  3265.  
  3266.  
  3267. ΓòÉΓòÉΓòÉ 6.2.15. SSRefCount ΓòÉΓòÉΓòÉ
  3268.  
  3269.  Concepts 
  3270.  Constructors 
  3271.  refInc 
  3272.  refDec 
  3273.  refFree 
  3274.  
  3275.  
  3276. ΓòÉΓòÉΓòÉ 6.2.15.1. Concepts ΓòÉΓòÉΓòÉ
  3277.  
  3278. The SSRefCount class implements reference counting for classes derived from it. 
  3279. See Reference Counting for a complete discussion. 
  3280.  
  3281. You must implement the refFree virtual function for all classes derived from 
  3282. SSRefCount, either directly or indirectly. 
  3283.  
  3284.  
  3285. ΓòÉΓòÉΓòÉ 6.2.15.2. Constructors ΓòÉΓòÉΓòÉ
  3286.  
  3287. The constructor initializes the reference count to 1. 
  3288.  
  3289. Signature 
  3290.  
  3291. SSRefCount::SSRefCount( void);
  3292.  
  3293. Example 
  3294.  
  3295. class MyRefCountedClass : public SSRefCount
  3296.    {
  3297.    ┬╖
  3298.    ┬╖
  3299.    ┬╖
  3300.    };
  3301.  
  3302. MyRefCountClass zMyClass; /* Reference count is 1 */
  3303.  
  3304.  
  3305. ΓòÉΓòÉΓòÉ 6.2.15.3. refInc ΓòÉΓòÉΓòÉ
  3306.  
  3307. The refInc virtual function increments the use count. 
  3308.  
  3309. Signature 
  3310.  
  3311. virtual void SSRefCount::refInc( void);
  3312.  
  3313. Example 
  3314.  
  3315. Assume you are passed a C++ reference to a SSLexLexeme object in qLexeme. 
  3316.  
  3317. typedef SSRef< SSLexLexeme> SSLexLexemeRef;
  3318.  
  3319. SSLexLexemeRef zRef( qLexeme);
  3320. zRef.refInc();
  3321.  
  3322.  
  3323. ΓòÉΓòÉΓòÉ 6.2.15.4. refDec ΓòÉΓòÉΓòÉ
  3324.  
  3325. The refDec virtual function decrements the use count.  If the count is 0 and 
  3326. the parameter is SSTrue, refFree is called to delete the object. 
  3327.  
  3328. Signature 
  3329.  
  3330. virtual void SSRefCount::refDec( SSBooleanValue = SSTrue);
  3331.  
  3332.  Parameters          Meaning 
  3333.  
  3334.  SSBooleanValue      A boolean value used to control deleting the object.  The 
  3335.                      refFree function is only called if the count is 0 and the 
  3336.                      boolean value is SSTrue.  This is useful for initializing 
  3337.                      a use count to 0, without deleting the object. 
  3338.  
  3339.  Example 
  3340.  
  3341.  This is the default SSYacc::stackElement virtual function.  Note that the use 
  3342.  count is set to 0 with refDec before returning.  This essentially passes 
  3343.  ownership of the object to the caller of stackElement. 
  3344.  
  3345.   SSYaccStackElement* SSYacc::stackElement( void)
  3346.      {
  3347.      SSYaccStackElement* zpElement = new SSYaccStackElement; /* Count is 1 */
  3348.      zpElement->refDec( SSFalse); /* Count is now 0 */
  3349.      return zpElement;
  3350.      }
  3351.  
  3352.  
  3353. ΓòÉΓòÉΓòÉ 6.2.15.5. refFree ΓòÉΓòÉΓòÉ
  3354.  
  3355. The refFree virtual function is called to delete an object. Usually, the only 
  3356. statement in the function is delete this. You must supply a refFree function 
  3357. for each class derived from SSRefCount, either directly or through another base 
  3358. class. 
  3359.  
  3360. Signature 
  3361.  
  3362. virtual void SSRefCount::refFree( void);
  3363.  
  3364. Example 
  3365.  
  3366. This is the default SSYaccStackElement::refFree virtual function. 
  3367.  
  3368. void SSYaccStackElement::refFree( void)
  3369.    {
  3370.    delete this;
  3371.    }
  3372.  
  3373.  
  3374. ΓòÉΓòÉΓòÉ 6.3. C ΓòÉΓòÉΓòÉ
  3375.  
  3376.  Concepts 
  3377.  SSLex 
  3378.  SSLexTable 
  3379.  SSLexLexeme 
  3380.  SSLexConsumer 
  3381.  SSYacc 
  3382.  SSYaccTable 
  3383.  SSYaccStackElement 
  3384.  SSException 
  3385.  
  3386.  
  3387. ΓòÉΓòÉΓòÉ 6.3.1. Concepts ΓòÉΓòÉΓòÉ
  3388.  
  3389. The C functions are architecturally similar to their C++ cousins. Instead of 
  3390. calling virtual functions to process actions, the C functions invoke callbacks 
  3391. to do the work. There is an equivalent C callback for almost every C++ virtual 
  3392. function. Usually, the only code you need to write is in the the reduce 
  3393. function generated by Visual Parse++, as with the C++ bindings. 
  3394.  
  3395. Perhaps the main difference lies in the application setup. For C++, application 
  3396. setup is trivial, the constructors do most of the work. For C, you call Create 
  3397. type functions to create the various pieces (consumer, lexer, etc.). Create 
  3398. functions return a correlator or handle, which is required on other functions. 
  3399. For instance, SSYaccCreate creates a parser, and returns a parser correlator. 
  3400. Functions related to the parser require this correlator.  If a bad correlator 
  3401. is detected, the default behavior is to abort. The 
  3402. SSExceptionSetBadCorrelatorCallback function is provided to set a user supplied 
  3403. bad correlator callback. This is useful during development. Your bad correlator 
  3404. callback can issue some kind of diagnostic message before aborting. See 
  3405. SSExceptionSetBadCorrelatorCallback for more information. 
  3406.  
  3407.  
  3408. ΓòÉΓòÉΓòÉ 6.3.2. SSLex ΓòÉΓòÉΓòÉ
  3409.  
  3410.  Concepts 
  3411.  SSLexClearLastException 
  3412.  SSLexCreate 
  3413.  SSLexDestroy 
  3414.  SSLexGetNextLexeme 
  3415.  SSLexGetLastException 
  3416.  SSLexGotoExpressionList 
  3417.  SSLexIsCurrentExpressionList 
  3418.  SSLexPopExpressionList 
  3419.  SSLexPushExpressionList 
  3420.  SSLexReset 
  3421.  SSLexSetLexemeExtra 
  3422.  SSLexSetCompleteCallback 
  3423.  SSLexSetErrorCallback 
  3424.  
  3425.  
  3426. ΓòÉΓòÉΓòÉ 6.3.2.1. Concepts ΓòÉΓòÉΓòÉ
  3427.  
  3428. The SSLex functions create and control lexical analyzers. A lexical analyzer 
  3429. requires two things to operate, a consumer correlator, and a lex table 
  3430. correlator. The consumer correlator is created with the SSLexConsumerCreate or 
  3431. SSLexFileConsumerCreate function. The table is created with the 
  3432. SSLexTableCreate function. 
  3433.  
  3434. There are two callbacks associated with a lexical analyzer, a 
  3435. SSLexErrorCallback (error callback) and a SSLexCompleteCallback (complete 
  3436. callback). Neither callback is required. 
  3437.  
  3438. The error callback is invoked when an invalid lexeme is detected. It can ignore 
  3439. the lexeme and continue, or repair and use the lexeme. The default callback 
  3440. discards the lexeme and continues. Typically, the error callback will issue 
  3441. some kind of diagnostic message and continue by ignoring the lexeme. 
  3442.  
  3443. The complete callback is called each time a lexeme is recognized. You can 
  3444. modify the lexeme, or terminate the lexical analyzer by returning SSFalse from 
  3445. the complete callback. The main use of the complete callback is to examine 
  3446. and/or modify a lexeme before it is passed to the parser. The default complete 
  3447. callback returns SSTrue. 
  3448.  
  3449.  
  3450. ΓòÉΓòÉΓòÉ 6.3.2.2. SSLexClearLastException ΓòÉΓòÉΓòÉ
  3451.  
  3452. The SSLexClearLastException clears any pending exceptions. 
  3453.  
  3454. Signature 
  3455.  
  3456. void SSLexClearLastException( void*);
  3457.  
  3458.  Parameters          Meaning 
  3459.  
  3460.  void*               A lex correlator. 
  3461.  
  3462.  Example 
  3463.  
  3464.   SSLexClearLastException( zpLex);
  3465.  
  3466.  
  3467. ΓòÉΓòÉΓòÉ 6.3.2.3. SSLexCreate ΓòÉΓòÉΓòÉ
  3468.  
  3469. The SSLexCreate function creates a lexical analyzer. 
  3470.  
  3471. Signature 
  3472.  
  3473. void* SSLexCreate( void*, void*, void**);
  3474.  
  3475.  Parameters          Meaning 
  3476.  
  3477.  void*               A consumer correlator. 
  3478.  
  3479.  void*               A lex table correlator. 
  3480.  
  3481.  void**              An address that is updated with an exception correlator if 
  3482.                      an error occurs. 
  3483.  
  3484.  Returns 
  3485.  
  3486.  A lex correlator or 0. Zero indicates an error occurred, examine the returned 
  3487.  exception correlator. 
  3488.  
  3489.  Example 
  3490.  
  3491.  Assume that zpTable contains a lex table correlator, and zpConsumer contains a 
  3492.  consumer correlator. 
  3493.  
  3494.   void* zpLex;
  3495.   void* zpException;
  3496.  
  3497.   zpLex = SSLexCreate( zpConsumer, zpTable, &zpException);
  3498.   if ( !zpLex)
  3499.      printf( "LexCreate failed %s", SSExceptionGetMessage( zpException));
  3500.  
  3501.  
  3502. ΓòÉΓòÉΓòÉ 6.3.2.4. SSLexDestroy ΓòÉΓòÉΓòÉ
  3503.  
  3504. The SSLexDestroy destroys a lexical analyzer. 
  3505.  
  3506. Signature 
  3507.  
  3508. void SSLexDestroy( void*);
  3509.  
  3510.  Parameters          Meaning 
  3511.  
  3512.  void*               A lex correlator. 
  3513.  
  3514.  Example 
  3515.  
  3516.   SSLexDestroy( zpLex);
  3517.  
  3518.  
  3519. ΓòÉΓòÉΓòÉ 6.3.2.5. SSLexGetNextLexeme ΓòÉΓòÉΓòÉ
  3520.  
  3521. The SSLexGetNextLexeme function retrieves the next lexeme. This function is 
  3522. used by standalone lexical analyzers to get lexemes, normally the parser 
  3523. fetches lexemes. 
  3524.  
  3525. Signature 
  3526.  
  3527. void* SSLexGetNextLexeme( void*);
  3528.  
  3529.  Parameters          Meaning 
  3530.  
  3531.  void*               A lex correlator. 
  3532.  
  3533.  Returns 
  3534.  
  3535.  A lexeme correlator or 0. Zero indicates end of data. 
  3536.  
  3537.  Example 
  3538.  
  3539.   void* zpLexeme;
  3540.   while ( zpLexeme = SSLexGetNextLexeme( zpLex))
  3541.      {
  3542.      /* Process lexeme */
  3543.      }
  3544.  
  3545.  
  3546. ΓòÉΓòÉΓòÉ 6.3.2.6. SSLexGetLastException ΓòÉΓòÉΓòÉ
  3547.  
  3548. The SSLexGetLastException function retrieves the last exception. This function 
  3549. should be used when a lexer has terminated, to determine if an exception caused 
  3550. the termination. SSException... functions can be used to get the error code and 
  3551. error message associated with the exception. 
  3552.  
  3553. Signature 
  3554.  
  3555. void* SSLexGetNextLexeme( void*);
  3556.  
  3557.  Parameters          Meaning 
  3558.  
  3559.  void*               A lex correlator. 
  3560.  
  3561.  Returns 
  3562.  
  3563.  An exception correlator or 0. Zero indicates that no exception occurred. 
  3564.  
  3565.  Example 
  3566.  
  3567.   void* zpLexeme;
  3568.   void* zpException;
  3569.  
  3570.   while ( zpLexeme = SSLexGetNextLexeme( zpLex))
  3571.      {
  3572.      /* Process lexeme */
  3573.      }
  3574.  
  3575.   if ( zpException = SSLexGetLastException( zpLex))
  3576.      {
  3577.      /* Process exception */
  3578.      }
  3579.  
  3580.  
  3581. ΓòÉΓòÉΓòÉ 6.3.2.7. SSLexGotoExpressionList ΓòÉΓòÉΓòÉ
  3582.  
  3583. The SSLexGotoExpressionList function pops and then pushes an expression list on 
  3584. the expression list stack. It performs the exact same function as %goto does in 
  3585. a rule file. 
  3586.  
  3587. Signature 
  3588.  
  3589. SSBooleanValue SSLexGotoExpressionList( void*, SSUnsigned32);
  3590.  
  3591.  Parameters          Meaning 
  3592.  
  3593.  void*               A lex correlator. 
  3594.  
  3595.  SSUnsigned32        An expression list identifier generated by Visual Parse++. 
  3596.  
  3597.  Returns 
  3598.  
  3599.  A success indication. SSTrue means the function failed, use 
  3600.  SSLexGetLastException to determine the reason. 
  3601.  
  3602.  Example 
  3603.  
  3604.   #define SSLexExpressionListMain 0 /* Defined in header file */
  3605.   void* zpException;
  3606.  
  3607.   if ( SSLexGotoExpressionList( zpLex, SSLexExpressionListMain))
  3608.      {
  3609.      zpException = SSLexGetLastException( zpLex);
  3610.      printf( "Goto error, %s\n", SSExceptionGetMessage( zpException));
  3611.      }
  3612.  
  3613.  
  3614. ΓòÉΓòÉΓòÉ 6.3.2.8. SSLexIsCurrentExpressionList ΓòÉΓòÉΓòÉ
  3615.  
  3616. The SSLexIsCurrentExpressionList function queries the top of the expression 
  3617. list stack. 
  3618.  
  3619. Signature 
  3620.  
  3621. SSBooleanValue SSLexIsCurrentExpressionList( void*, SSUnsigned32);
  3622.  
  3623.  Parameters          Meaning 
  3624.  
  3625.  void*               A lex correlator. 
  3626.  
  3627.  SSUnsigned32        An expression list identifier generated by Visual Parse++. 
  3628.  
  3629.  Returns 
  3630.  
  3631.  A success indication. SSTrue means the expression list is on top of the stack. 
  3632.  
  3633.  Example 
  3634.  
  3635.   #define SSLexExpressionListMain 0 /* Defined in header file */
  3636.   if ( SSLexIsCurrentExpressionList( zpLex, SSLexExpressionListMain))
  3637.      {
  3638.      /* Expression list Main is on top of the expression list stack */
  3639.      }
  3640.  
  3641.  
  3642. ΓòÉΓòÉΓòÉ 6.3.2.9. SSLexPopExpressionList ΓòÉΓòÉΓòÉ
  3643.  
  3644. The SSLexPopExpressionList function pops the top expression list of the 
  3645. expression list stack. It performs the exact same function as %pop does in a 
  3646. rule file. 
  3647.  
  3648. Signature 
  3649.  
  3650. SSBooleanValue SSLexPopExpressionList( void*);
  3651.  
  3652.  Parameters          Meaning 
  3653.  
  3654.  void*               A lex correlator. 
  3655.  
  3656.  Returns 
  3657.  
  3658.  A success indication. SSTrue means the pop failed, use SSLexGetLastException 
  3659.  to determine the reason. 
  3660.  
  3661.  Example 
  3662.  
  3663.   #define SSLexExpressionListMain 0 /* Defined in header file */
  3664.   void* zpException;
  3665.  
  3666.   if ( SSLexGotoExpressionList( zpLex, SSLexExpressionListMain))
  3667.      {
  3668.      zpException = SSLexGetLastException( zpLex);
  3669.      printf( "Pop error, %s\n", SSExceptionGetMessage( zpException));
  3670.      }
  3671.  
  3672.  
  3673. ΓòÉΓòÉΓòÉ 6.3.2.10. SSLexPushExpressionList ΓòÉΓòÉΓòÉ
  3674.  
  3675. The SSLexPushExpressionList function pushes an expression list on the 
  3676. expression list stack. It performs the exact same function as %push does in a 
  3677. rule file. 
  3678.  
  3679. Signature 
  3680.  
  3681. SSBooleanValue SSLexPushExpressionList( void*, SSUnsigned32);
  3682.  
  3683.  Parameters          Meaning 
  3684.  
  3685.  void*               A lex correlator. 
  3686.  
  3687.  SSUnsigned32        An expression list identifier generated by Visual Parse++. 
  3688.  
  3689.  Returns 
  3690.  
  3691.  A success indication. SSTrue means the function failed, use 
  3692.  SSLexGetLastException to determine the reason. 
  3693.  
  3694.  Example 
  3695.  
  3696.   #define SSLexExpressionListMain 0 /* Defined in header file */
  3697.   void* zpException;
  3698.  
  3699.   if ( SSLexPushExpressionList( zpLex, SSLexExpressionListMain))
  3700.      {
  3701.      zpException = SSLexGetLastException( zpLex);
  3702.      printf( "Push error, %s\n", SSExceptionGetMessage( zpException));
  3703.      }
  3704.  
  3705.  
  3706. ΓòÉΓòÉΓòÉ 6.3.2.11. SSLexReset ΓòÉΓòÉΓòÉ
  3707.  
  3708. SSLexReset resets the lexer to its initial state. 
  3709.  
  3710. Signature 
  3711.  
  3712. void SSLexPushExpressionList( void*);
  3713.  
  3714.  Parameters          Meaning 
  3715.  
  3716.  void*               A lex correlator. 
  3717.  
  3718.  Example 
  3719.  
  3720.   SSLexReset( zpLex);
  3721.  
  3722.  
  3723. ΓòÉΓòÉΓòÉ 6.3.2.12. SSLexSetLexemeExtra ΓòÉΓòÉΓòÉ
  3724.  
  3725. The SSLexSetLexemeExtra function sets the size of the area reserved for the 
  3726. programmer's use in a lexeme, for lexemes that Visual Parse++ allocates. You 
  3727. can access this area with the SSLexLexemeGetExtraLength and 
  3728. SSLexLexemeGetExtraBuffer functions. 
  3729.  
  3730. Signature 
  3731.  
  3732. void SSLexSetLexemeExtra( void*, SSUnsigned32);
  3733.  
  3734.  Parameters          Meaning 
  3735.  
  3736.  void*               A lex correlator. 
  3737.  
  3738.  SSUnsigned32        The extra length. 
  3739.  
  3740.  Example 
  3741.  
  3742.   SSLexSetLexemeExtra( 16);
  3743.  
  3744.  
  3745. ΓòÉΓòÉΓòÉ 6.3.2.13. SSLexSetCompleteCallback ΓòÉΓòÉΓòÉ
  3746.  
  3747. The SSLexSetCompleteCallback function sets the complete callback. The complete 
  3748. callback is called each time a lexeme is recognized. You can examine and/or 
  3749. modify the lexeme and continue or terminate processing. The prototype of the 
  3750. callback is discussed below. 
  3751.  
  3752. Signature 
  3753.  
  3754. void SSLexSetCompleteCallback( void*, SSLexCompleteCallback, void*);
  3755.  
  3756.  Parameters          Meaning 
  3757.  
  3758.  void*               A lex correlator. 
  3759.  
  3760.  SSLexCompleteCallback The callback address. 
  3761.  
  3762.  void*               A parameter to pass to the callback. 
  3763.  
  3764.  The callback function prototype looks like: 
  3765.  
  3766.   SSBooleanValue callback( void*, void*, void*);
  3767.  
  3768.  Parameters          Meaning 
  3769.  
  3770.  void*               A lex correlator. 
  3771.  
  3772.  void*               A lexeme correlator. 
  3773.  
  3774.  void*               The parameter specified on SSLexSetCompleteCallback. 
  3775.  
  3776.  Returns 
  3777.  
  3778.  A success indication. SSTrue means continue processing, SSFalse to terminate 
  3779.  processing. If the parser invoked the lexer terminating processing will cause 
  3780.  an end of data indication to be sent to the parser. 
  3781.  
  3782.  Example 
  3783.  
  3784.  Assume zpConsumer and zpTable contain a consumer and table correlator, 
  3785.  respectively. 
  3786.  
  3787.   void* zpLex = SSLexCreate( zpConsumer, zpTable);
  3788.   SSLexSetCompleteCallback( zpLex, MyCallback, 0);
  3789.   ┬╖
  3790.   ┬╖
  3791.   ┬╖
  3792.   SSRetBool MyCallback( void* qpLex, void* qpLexeme, void* qpParm)
  3793.      {
  3794.      /* examine and/or modify lexeme */
  3795.      return SSTrue; /* Continue normally */
  3796.      }
  3797.  
  3798.  
  3799. ΓòÉΓòÉΓòÉ 6.3.2.14. SSLexSetErrorCallback ΓòÉΓòÉΓòÉ
  3800.  
  3801. The SSLexSetErrorCallback function sets the error callback. The error callback 
  3802. is called when an invalid lexeme is detected. You can examine and/or modify the 
  3803. lexeme and continue processing or ignore the lexeme. The prototype of the 
  3804. callback is discussed below. 
  3805.  
  3806. Signature 
  3807.  
  3808. void SSLexSetErrorCallback( void*, SSLexErrorCallback, void*);
  3809.  
  3810.  Parameters          Meaning 
  3811.  
  3812.  void*               A lex correlator. 
  3813.  
  3814.  SSLexErrorCallback  The callback address. 
  3815.  
  3816.  void*               A parameter to pass to the callback. 
  3817.  
  3818.  The callback function prototype looks like: 
  3819.  
  3820.   SSBooleanValue callback( void*, void*, void*);
  3821.  
  3822.  Parameters          Meaning 
  3823.  
  3824.  void*               A lex correlator. 
  3825.  
  3826.  void*               The correlator of the invalid lexeme. 
  3827.  
  3828.  void*               The parameter specified on SSLexSetErrorCallback. 
  3829.  
  3830.  Returns 
  3831.  
  3832.  A success indication. SSTrue means continue processing, SSFalse to ignore the 
  3833.  lexeme and continue. 
  3834.  
  3835.  Example 
  3836.  
  3837.  Assume zpConsumer and zpTable contain a consumer and table correlator, 
  3838.  respectively. 
  3839.  
  3840.   void* zpLex = SSLexCreate( zpConsumer, zpTable);
  3841.   SSLexSetErrorCallback( zpLex, MyCallback, 0);
  3842.   ┬╖
  3843.   ┬╖
  3844.   ┬╖
  3845.   SSRetBool MyCallback( void* qpLex, void* qpLexeme, void* qpParm)
  3846.      {
  3847.      char* zpchBuff = ( char*) SSLexLexemeGetBuffer( qpLexeme);
  3848.      SSUnsigned32 zulLine = SSLexLexemeGetLine( qpLexeme);
  3849.      SSUnsigned32 zulOffset = SSLexLexemeGetOffset( qpLexeme);
  3850.      printf( "Invalid lexeme %s, on line %d at offset %d\n", zpchBuff,
  3851.         zulLine, zulOffet);
  3852.      return SSFalse; /* Ignore lexeme */
  3853.      }
  3854.  
  3855.  
  3856. ΓòÉΓòÉΓòÉ 6.3.3. SSLexTable ΓòÉΓòÉΓòÉ
  3857.  
  3858.  Concepts 
  3859.  SSLexTableCreate 
  3860.  SSLexTableDestroy 
  3861.  
  3862.  
  3863. ΓòÉΓòÉΓòÉ 6.3.3.1. Concepts ΓòÉΓòÉΓòÉ
  3864.  
  3865. The SSLexTable functions create and destroy lexical analyzer tables. They 
  3866. correspond to the C++ SSLexTable class. 
  3867.  
  3868.  
  3869. ΓòÉΓòÉΓòÉ 6.3.3.2. SSLexTableCreate ΓòÉΓòÉΓòÉ
  3870.  
  3871. The SSLexTableCreate function creates a lexical analyzer table. 
  3872.  
  3873. Signature 
  3874.  
  3875. void* SSLexTableCreate( const char*, void**);
  3876.  
  3877.  Parameters          Meaning 
  3878.  
  3879.  const char*         The table name. 
  3880.  
  3881.  void**              An address that is updated with an exception correlator if 
  3882.                      an exception occurs. 
  3883.  
  3884.  Returns 
  3885.  
  3886.  A lex table correlator or 0. If zero is returned, examine the exception 
  3887.  correlator to determine the cause of the error. 
  3888.  
  3889.  Example 
  3890.  
  3891.   void* zpTable;
  3892.   void* zpException;
  3893.  
  3894.   zpTable = SSLexTableCreate( "table.dfa", &zpException);
  3895.   if ( !zpTable)
  3896.      printf( "SSLexTableCreate failed %s", SSExceptionGetMessage( zpException));
  3897.  
  3898.  
  3899. ΓòÉΓòÉΓòÉ 6.3.3.3. SSLexTableDestroy ΓòÉΓòÉΓòÉ
  3900.  
  3901. SSLexTableDestroy destroys a lexical analyzer table. 
  3902.  
  3903. Signature 
  3904.  
  3905. void SSLexTableDestroy( void*);
  3906.  
  3907.  Parameters          Meaning 
  3908.  
  3909.  void*               A lex table correlator. 
  3910.  
  3911.  Example 
  3912.  
  3913.   SSLexTableDestroy( zpTable);
  3914.  
  3915.  
  3916. ΓòÉΓòÉΓòÉ 6.3.4. SSLexLexeme ΓòÉΓòÉΓòÉ
  3917.  
  3918.  Concepts 
  3919.  SSLexLexemeCreate 
  3920.  SSLexLexemeDestroy 
  3921.  SSLexLexemeGetBuffer 
  3922.  SSLexLexemeGetExtraBuffer 
  3923.  SSLexLexemeGetExtraLength 
  3924.  SSLexLexemeGetLength 
  3925.  SSLexLexemeGetLine 
  3926.  SSLexLexemeGetOffset 
  3927.  SSLexLexemeGetToken 
  3928.  SSLexLexemeGetType 
  3929.  SSLexLexemeRefInc 
  3930.  SSLexLexemeRefDec 
  3931.  SSLexLexemeSetBuffer 
  3932.  SSLexLexemeSetLength 
  3933.  SSLexLexemeSetLine 
  3934.  SSLexLexemeSetOffset 
  3935.  SSLexLexemeSetToken 
  3936.  SSLexLexemeSetType 
  3937.  
  3938.  
  3939. ΓòÉΓòÉΓòÉ 6.3.4.1. Concepts ΓòÉΓòÉΓòÉ
  3940.  
  3941. The SSLexLexeme functions create and operate on lexemes. They correspond to the 
  3942. C++ SSLexLexeme class. 
  3943.  
  3944.  
  3945. ΓòÉΓòÉΓòÉ 6.3.4.2. SSLexLexemeCreate ΓòÉΓòÉΓòÉ
  3946.  
  3947. The SSLexLexemeCreate function creates a lexeme. The data specified is copied 
  3948. to the lexeme (and null terminated for your convenience). The SSLexLexemeSet... 
  3949. functions can be used to update the lexeme parameters (type, token, etc.). This 
  3950. function is mainly supplied for programmers using the SSYaccNextLexemeCallback. 
  3951. Normally, you let Visual Parse++ allocate lexemes for you. 
  3952.  
  3953. Signature 
  3954.  
  3955. void* SSLexLexemeCreate( void*, SSUnsigned32, SSUnsigned32, void**);
  3956.  
  3957.  Parameters          Meaning 
  3958.  
  3959.  void*               A data pointer. 
  3960.  
  3961.  SSUnsigned32        The data length. 
  3962.  
  3963.  SSUnsigned32        The extra length allocated in the lexeme, but reserved for 
  3964.                      the programmer's use. 
  3965.  
  3966.  void**              An address that is updated with an exception correlator if 
  3967.                      an exception occurs. 
  3968.  
  3969.  Returns 
  3970.  
  3971.  A lexeme correlator or 0. If zero is returned, examine the exception 
  3972.  correlator to determine the cause of the error. 
  3973.  
  3974.  Example 
  3975.  
  3976.   void* zpLexeme;
  3977.   void* zpException;
  3978.  
  3979.   zpLexeme = SSLexLexemeCreate( "Data", strlen( "Data"), 0, &zpException);
  3980.   if ( !zpLexeme)
  3981.      printf( "SSLexLexemeCreate failed %s", SSExceptionGetMessage( zpException));
  3982.  
  3983.  
  3984. ΓòÉΓòÉΓòÉ 6.3.4.3. SSLexLexemeDestroy ΓòÉΓòÉΓòÉ
  3985.  
  3986. The SSLexLexemeDestroy function destroys a lexeme. If you are using a parser, 
  3987. use this function with extreme caution, if at all. Reference counting is used 
  3988. to control the lifetimes of lexemes, issuing this function could free a lexeme 
  3989. that is in use by Visual Parse++. This function is only required for standalone 
  3990. lexical analyzers. 
  3991.  
  3992. Signature 
  3993.  
  3994. void SSLexLexemeCreate( void*);
  3995.  
  3996.  Parameters          Meaning 
  3997.  
  3998.  void*               A lexeme correlator. 
  3999.  
  4000.  
  4001. ΓòÉΓòÉΓòÉ 6.3.4.4. SSLexLexemeGetBuffer ΓòÉΓòÉΓòÉ
  4002.  
  4003. The SSLexLexemeGetBuffer returns the buffer pointer. Lexeme buffers are null 
  4004. terminated, so C string functions can be used. 
  4005.  
  4006. Signature 
  4007.  
  4008. void* SSLexLexemeGetBuffer( void*);
  4009.  
  4010.  Parameters          Meaning 
  4011.  
  4012.  void*               A lexeme correlator. 
  4013.  
  4014.  Returns 
  4015.  
  4016.  The buffer pointer. 
  4017.  
  4018.  Example 
  4019.  
  4020.   void* zpBuff = SSLexLexemeGetBuffer( zpLexeme);
  4021.  
  4022.  
  4023. ΓòÉΓòÉΓòÉ 6.3.4.5. SSLexLexemeGetExtraBuffer ΓòÉΓòÉΓòÉ
  4024.  
  4025. The SSLexLexemeGetExtraBuffer returns the extra buffer pointer. This is the 
  4026. area reserved in the lexeme for the programmer's use. 
  4027.  
  4028. Signature 
  4029.  
  4030. void* SSLexLexemeGetExtraBuffer( void*);
  4031.  
  4032.  Parameters          Meaning 
  4033.  
  4034.  void*               A lexeme correlator. 
  4035.  
  4036.  Returns 
  4037.  
  4038.  The buffer pointer. 
  4039.  
  4040.  Example 
  4041.  
  4042.   void* zpBuff = SSLexLexemeGetExtraBuffer( zpLexeme);
  4043.  
  4044.  
  4045. ΓòÉΓòÉΓòÉ 6.3.4.6. SSLexLexemeGetExtraLength ΓòÉΓòÉΓòÉ
  4046.  
  4047. The SSLexLexemeGetExtraLength function returns the extra buffer length. It was 
  4048. set on SSLexLexemeCreate or SSLexSetLexemeExtra function. 
  4049.  
  4050. Signature 
  4051.  
  4052. SSUnsigned32 SSLexLexemeGetExtraLength( void*);
  4053.  
  4054.  Parameters          Meaning 
  4055.  
  4056.  void*               A lexeme correlator. 
  4057.  
  4058.  Returns 
  4059.  
  4060.  The extra buffer length. 
  4061.  
  4062.  Example 
  4063.  
  4064.   SSUnsigned32 zulLen = SSLexLexemeGetExtraLength( zpLexeme);
  4065.  
  4066.  
  4067. ΓòÉΓòÉΓòÉ 6.3.4.7. SSLexLexemeGetLength ΓòÉΓòÉΓòÉ
  4068.  
  4069. The SSLexLexemeGetLength function returns the buffer length. 
  4070.  
  4071. Signature 
  4072.  
  4073. SSUnsigned32 SSLexLexemeGetLength( void*);
  4074.  
  4075.  Parameters          Meaning 
  4076.  
  4077.  void*               A lexeme correlator. 
  4078.  
  4079.  Returns 
  4080.  
  4081.  The buffer length. 
  4082.  
  4083.  Example 
  4084.  
  4085.   SSUnsigned32 zulLen = SSLexLexemeGetLength( zpLexeme);
  4086.  
  4087.  
  4088. ΓòÉΓòÉΓòÉ 6.3.4.8. SSLexLexemeGetLine ΓòÉΓòÉΓòÉ
  4089.  
  4090. The SSLexLexemeGetLine function returns the line number. 
  4091.  
  4092. Signature 
  4093.  
  4094. SSUnsigned32 SSLexLexemeGetLine( void*);
  4095.  
  4096.  Parameters          Meaning 
  4097.  
  4098.  void*               A lexeme correlator. 
  4099.  
  4100.  Returns 
  4101.  
  4102.  The line number. 
  4103.  
  4104.  Example 
  4105.  
  4106.   SSUnsigned32 zulLine = SSLexLexemeGetLine( zpLexeme);
  4107.  
  4108.  
  4109. ΓòÉΓòÉΓòÉ 6.3.4.9. SSLexLexemeGetOffset ΓòÉΓòÉΓòÉ
  4110.  
  4111. The SSLexLexemeGetOffset function returns the line offset. 
  4112.  
  4113. Signature 
  4114.  
  4115. SSUnsigned32 SSLexLexemeGetLength( void*);
  4116.  
  4117.  Parameters          Meaning 
  4118.  
  4119.  void*               A lexeme correlator. 
  4120.  
  4121.  Returns 
  4122.  
  4123.  The line offset. 
  4124.  
  4125.  Example 
  4126.  
  4127.   SSUnsigned32 zulOffset = SSLexLexemeGetOffset( zpLexeme);
  4128.  
  4129.  
  4130. ΓòÉΓòÉΓòÉ 6.3.4.10. SSLexLexemeGetToken ΓòÉΓòÉΓòÉ
  4131.  
  4132. The SSLexLexemeGetToken function returns the token number. 
  4133.  
  4134. Signature 
  4135.  
  4136. SSUnsigned32 SSLexLexemeGetToken( void*);
  4137.  
  4138.  Parameters          Meaning 
  4139.  
  4140.  void*               A lexeme correlator. 
  4141.  
  4142.  Returns 
  4143.  
  4144.  The token number. 
  4145.  
  4146.  Example 
  4147.  
  4148.   SSUnsigned32 zulToken = SSLexLexemeGetToken( zpLexeme);
  4149.  
  4150.  
  4151. ΓòÉΓòÉΓòÉ 6.3.4.11. SSLexLexemeGetType ΓòÉΓòÉΓòÉ
  4152.  
  4153. The SSLexLexemeGetType function returns the lexeme type, either 
  4154. SSLexLexemeTypeDBCS or SSLexLexemeTypeUnicode. These symbols are defined in 
  4155. sslexc.h. 
  4156.  
  4157. Signature 
  4158.  
  4159. SSUnsigned32 SSLexLexemeGetType( void*);
  4160.  
  4161.  Parameters          Meaning 
  4162.  
  4163.  void*               A lexeme correlator. 
  4164.  
  4165.  Returns 
  4166.  
  4167.  The type. 
  4168.  
  4169.  Example 
  4170.  
  4171.   SSUnsigned32 zulType = SSLexLexemeGetType( zpLexeme);
  4172.  
  4173.  
  4174. ΓòÉΓòÉΓòÉ 6.3.4.12. SSLexLexemeRefInc ΓòÉΓòÉΓòÉ
  4175.  
  4176. SSLexLexemeRefInc increments the reference count for the lexeme. The lexeme 
  4177. will not be released until the reference count is 0. This function is useful 
  4178. for extending the lifetime of a lexeme. Normally, lexemes are deleted after a 
  4179. reduce has been performed by the parser, use this function if you want access 
  4180. to the lexeme after this point. When you are through with the lexeme, use 
  4181. SSLexLexemeRefDec to release the lexeme. 
  4182.  
  4183. Signature 
  4184.  
  4185. void SSLexLexemeRefInc( void*);
  4186.  
  4187.  Parameters          Meaning 
  4188.  
  4189.  void*               A lexeme correlator. 
  4190.  
  4191.  Example 
  4192.  
  4193.   SSLexLexemeRefInc( zpLexeme);
  4194.  
  4195.  
  4196. ΓòÉΓòÉΓòÉ 6.3.4.13. SSLexLexemeRefDec ΓòÉΓòÉΓòÉ
  4197.  
  4198. SSLexLexemeRefDec decrements the reference count for the lexeme. The lexeme 
  4199. will not be released until the reference count is 0. Only use SSLexLexemeRefDec 
  4200. if SSLexLexemeRefInc was used to increment the lexeme. 
  4201.  
  4202. Signature 
  4203.  
  4204. SSBooleanValue SSLexLexemeRefDec( void*);
  4205.  
  4206.  Parameters          Meaning 
  4207.  
  4208.  void*               A lexeme correlator. 
  4209.  
  4210.  Returns 
  4211.  
  4212.  SSTrue indicates that the reference count was already 0. You didn't issue a 
  4213.  SSLexLexemeRefInc for this lexeme. 
  4214.  
  4215.  Example 
  4216.  
  4217.   SSLexLexemeRefDec( zpLexeme);
  4218.  
  4219.  
  4220. ΓòÉΓòÉΓòÉ 6.3.4.14. SSLexLexemeSetBuffer ΓòÉΓòÉΓòÉ
  4221.  
  4222. The SSLexLexemeSetBuffer sets the buffer pointer. This function is rarely 
  4223. required, SSLexLexemeCreate or Visual Parse++ usually handles lexeme buffers. 
  4224.  
  4225. Signature 
  4226.  
  4227. void SSLexLexemeSetBuffer( void*);
  4228.  
  4229.  Parameters          Meaning 
  4230.  
  4231.  void*               The buffer pointer. 
  4232.  
  4233.  
  4234. ΓòÉΓòÉΓòÉ 6.3.4.15. SSLexLexemeSetLength ΓòÉΓòÉΓòÉ
  4235.  
  4236. The SSLexLexemeSetLength function sets the buffer length. This function is 
  4237. rarely required, SSLexLexemeCreate or Visual Parse++ usually sets the buffer 
  4238. length. 
  4239.  
  4240. Signature 
  4241.  
  4242. void SSLexLexemeSetLength( SSUnsigned32);
  4243.  
  4244.  Parameters          Meaning 
  4245.  
  4246.  SSUnsigned32        The length. 
  4247.  
  4248.  
  4249. ΓòÉΓòÉΓòÉ 6.3.4.16. SSLexLexemeSetLine ΓòÉΓòÉΓòÉ
  4250.  
  4251. The SSLexLexemeSetLine function sets the line number. 
  4252.  
  4253. Signature 
  4254.  
  4255. void SSLexLexemeSetLine( SSUnsigned32);
  4256.  
  4257.  Parameters          Meaning 
  4258.  
  4259.  SSUnsigned32        A line number. 
  4260.  
  4261.   SSLexLexemeSetLine( 15);
  4262.  
  4263.  
  4264. ΓòÉΓòÉΓòÉ 6.3.4.17. SSLexLexemeSetOffset ΓòÉΓòÉΓòÉ
  4265.  
  4266. The SSLexLexemeSetOffset function sets the line offset. 
  4267.  
  4268. Signature 
  4269.  
  4270. void SSLexLexemeSetOffset( SSUnsigned32);
  4271.  
  4272.  Parameters          Meaning 
  4273.  
  4274.  SSUnsigned32        The line offset. 
  4275.  
  4276.  Example 
  4277.  
  4278.   SSLexLexemeSetOffset( 55);
  4279.  
  4280.  
  4281. ΓòÉΓòÉΓòÉ 6.3.4.18. SSLexLexemeSetToken ΓòÉΓòÉΓòÉ
  4282.  
  4283. The SSLexLexemeSetToken function sets the token number. 
  4284.  
  4285. Signature 
  4286.  
  4287. void SSLexLexemeSetToken( SSUnsigned32);
  4288.  
  4289.  Parameters          Meaning 
  4290.  
  4291.  SSUnsigned32        A token number. 
  4292.  
  4293.  Example 
  4294.  
  4295.   SSLexLexemeSetToken( 2);
  4296.  
  4297.  
  4298. ΓòÉΓòÉΓòÉ 6.3.4.19. SSLexLexemeSetType ΓòÉΓòÉΓòÉ
  4299.  
  4300. The SSLexLexemeSetType function sets the lexeme type, either 
  4301. SSLexLexemeTypeDBCS or SSLexLexemeTypeUnicode. These symbols are defined in 
  4302. sslexc.h. 
  4303.  
  4304. Signature 
  4305.  
  4306. void SSLexLexemeSetType( SSUnsigned32);
  4307.  
  4308.  Parameters          Meaning 
  4309.  
  4310.  SSUnsigned32        Either SSLexLexemeTypeDBCS or SSLexLexemeTypeUnicode. 
  4311.  
  4312.  Example 
  4313.  
  4314.   SSLexLexemeSetType( SSLexLexemeTypeDBCS);
  4315.  
  4316.  
  4317. ΓòÉΓòÉΓòÉ 6.3.5. SSLexConsumer ΓòÉΓòÉΓòÉ
  4318.  
  4319.  Concepts 
  4320.  SSLexConsumerCreate 
  4321.  SSLexFileConsumerCreate 
  4322.  SSLexFileConsumerGetFile 
  4323.  SSLexFileConsumerCloseFile 
  4324.  SSLexConsumerDestroy 
  4325.  SSLexConsumerSetNextBufferCallback 
  4326.  
  4327.  
  4328. ΓòÉΓòÉΓòÉ 6.3.5.1. Concepts ΓòÉΓòÉΓòÉ
  4329.  
  4330. Consumers represent data that is processed by lexical analyzers. Each lexical 
  4331. analyzer requires a consumer to operate. SSLexConsumer functions provide access 
  4332. to consumers. 
  4333.  
  4334. There is one callback of interest to the programmer, a next buffer callback. 
  4335. The next buffer callback is not required, either a file consumer can be used, 
  4336. or all the data can be passed on SSLexConsumerCreate. 
  4337.  
  4338. The next buffer callback is set with SSLexConsumerSetNextBufferCallback 
  4339. function. The next buffer callback is invoked when more data is needed. It is 
  4340. passed a buffer address and length as parameters, and fills in the specified 
  4341. area with data. When end of data is reached, the next buffer callback returns 
  4342. 0. 
  4343.  
  4344.  
  4345. ΓòÉΓòÉΓòÉ 6.3.5.2. SSLexConsumerCreate ΓòÉΓòÉΓòÉ
  4346.  
  4347. The SSLexConsumerCreate function creates a consumer. The data supplied is 
  4348. copied to the consumer buffer. 
  4349.  
  4350. Signature 
  4351.  
  4352. void* SSLexConsumerCreate( void*, SSUnsigned32, SSUnsigned32,
  4353.    SSUnsigned32, void**);
  4354.  
  4355.  Parameters          Meaning 
  4356.  
  4357.  void*               A buffer pointer. 
  4358.  
  4359.  SSUnsigned32        The buffer length. 
  4360.  
  4361.  SSUnsigned32        The consumer type, either SSLexConsumerTypeBinary, 
  4362.                      SSLexConsumerTypeUnicode, or SSLexConsumerTypeCharacter. 
  4363.                      The binary type doesn't check for DBCS characters. 
  4364.  
  4365.  SSUnsigned32        The buffer increment. A value that will be used to expand 
  4366.                      the buffer, if necessary. If this value is 0, the largest 
  4367.                      lexeme that will be excepted is determined by the initial 
  4368.                      buffer length. 
  4369.  
  4370.  void**              An address that is updated with an exception correlator if 
  4371.                      an exception occurs. 
  4372.  
  4373.  Returns 
  4374.  
  4375.  A consumer correlator or 0. If zero is returned, examine the exception 
  4376.  correlator to determine the cause of the error. 
  4377.  
  4378.  Example 
  4379.  
  4380.   void* zpConsumer;
  4381.   void* zpException;
  4382.  
  4383.   zpConsumer = SSLexConsumerCreate( "Data", strlen( "Data"),
  4384.      SSLexConsumerTypeBinary, 0, &zpException);
  4385.   if ( !zpConsumer)
  4386.      printf( "SSLexConsumerCreate failed %s", SSExceptionGetMessage( zpException));
  4387.  
  4388.  
  4389. ΓòÉΓòÉΓòÉ 6.3.5.3. SSLexFileConsumerCreate ΓòÉΓòÉΓòÉ
  4390.  
  4391. The SSLexFileConsumerCreate function creates a file consumer. 
  4392.  
  4393. Signature 
  4394.  
  4395. void* SSLexConsumerFileCreate( const char*, SSUnsigned32, SSUnsigned32,
  4396.    SSUnsigned32, void**);
  4397.  
  4398.  Parameters          Meaning 
  4399.  
  4400.  const char*         A file name. 
  4401.  
  4402.  SSUnsigned32        The buffer size that is allocated. SSLexConsumerAll 
  4403.                      allocates a buffer the same size as the file. 
  4404.  
  4405.  SSUnsigned32        The buffer increment. A value that will be used to expand 
  4406.                      the buffer, if necessary. If this value is 0, the largest 
  4407.                      lexeme that will be excepted is determined by the initial 
  4408.                      buffer length. 
  4409.  
  4410.  SSUnsigned32        The consumer type, either SSLexConsumerTypeBinary, 
  4411.                      SSLexConsumerTypeUnicode, or SSLexConsumerTypeCharacter. 
  4412.                      The binary type doesn't check for DBCS characters and the 
  4413.                      file is opened rb. 
  4414.  
  4415.  void**              An address that is updated with an exception correlator if 
  4416.                      an exception occurs. 
  4417.  
  4418.  Returns 
  4419.  
  4420.  A consumer correlator or 0. If zero is returned, examine the exception 
  4421.  correlator to determine the cause of the error. 
  4422.  
  4423.  Example 
  4424.  
  4425.   void* zpConsumer;
  4426.   void* zpException;
  4427.  
  4428.   zpConsumer = SSLexFileConsumerCreate( "file.name", SSLexConsumerAll, 0,
  4429.      SSLexConsumerTypeCharacter, &zpException);
  4430.   if ( !zpConsumer)
  4431.      printf( "SSLexFileConsumerCreate failed %s", SSExceptionGetMessage( zpException));
  4432.  
  4433.  
  4434. ΓòÉΓòÉΓòÉ 6.3.5.4. SSLexFileConsumerGetFile ΓòÉΓòÉΓòÉ
  4435.  
  4436. SSLexFileConsumerGetFile returns the file pointer as a FILE*. 
  4437.  
  4438. Signature 
  4439.  
  4440. FILE* SSLexFileConsumerGetFile( void*);
  4441.  
  4442.  Parameters          Meaning 
  4443.  
  4444.  void*               A consumer correlator. 
  4445.  
  4446.  Returns 
  4447.  
  4448.  The file pointer. 
  4449.  
  4450.  Example 
  4451.  
  4452.   FILE* zpFile = SSLexFileConsumerGetFile( zpConsumer);
  4453.  
  4454.  
  4455. ΓòÉΓòÉΓòÉ 6.3.5.5. SSLexFileConsumerCloseFile ΓòÉΓòÉΓòÉ
  4456.  
  4457. SSLexFileConsumerCloseFile closes the file associated with the consumer. Do not 
  4458. close a file that is currently in use. 
  4459.  
  4460. Signature 
  4461.  
  4462. void SSLexFileConsumerCloseFile( void*);
  4463.  
  4464.  Parameters          Meaning 
  4465.  
  4466.  void*               A consumer correlator. 
  4467.  
  4468.  Example 
  4469.  
  4470.   SSLexFileConsumerCloseFile( zpConsumer);
  4471.  
  4472.  
  4473. ΓòÉΓòÉΓòÉ 6.3.5.6. SSLexConsumerDestroy ΓòÉΓòÉΓòÉ
  4474.  
  4475. SSLexConsumerDestroy destroys a consumer. Do not destroy a consumer that is 
  4476. currently in use. 
  4477.  
  4478. Signature 
  4479.  
  4480. void SSLexConsumerDestroy( void*);
  4481.  
  4482.  Parameters          Meaning 
  4483.  
  4484.  void*               A consumer correlator. 
  4485.  
  4486.  Example 
  4487.  
  4488.   SSLexConsumerDestroy( zpConsumer);
  4489.  
  4490.  
  4491. ΓòÉΓòÉΓòÉ 6.3.5.7. SSLexConsumerSetNextBufferCallback ΓòÉΓòÉΓòÉ
  4492.  
  4493. SSLexConsumerSetNextBufferCallback sets the next buffer callback. The next 
  4494. buffer callback is invoked when more data is needed by the lexical analyzer. 
  4495. The prototype is described below. 
  4496.  
  4497. Signature 
  4498.  
  4499. void SSLexConsumerSetNextBufferCallback( void*,
  4500.    SSLexConsumerNextBufferCallback, void*);
  4501.  
  4502.  Parameters          Meaning 
  4503.  
  4504.  void*               A consumer correlator. 
  4505.  
  4506.  SSLexConsumerNextBufferCallback The callback address. 
  4507.  
  4508.  void*               A parameter that is passed to the callback. 
  4509.  
  4510.  The callback fills in a buffer passed by Visual Parse++, and returns the 
  4511.  length of the data. The callback prototype looks like: 
  4512.  
  4513.   SSUnsigned32 callback( void*, void*, SSUnsigned32, void*);
  4514.  
  4515.  Parameters          Meaning 
  4516.  
  4517.  void*               The consumer correlator. 
  4518.  
  4519.  void*               The buffer pointer. 
  4520.  
  4521.  SSUnsigned32        The buffer length. 
  4522.  
  4523.  void*               The parameter specified when setting the callback. 
  4524.  
  4525.  Returns 
  4526.  
  4527.  The length of the data put in the buffer. Zero means end of data. 
  4528.  
  4529.  Example 
  4530.  
  4531.   SSLexConsumerSetNextBufferCallback( zpConsumer, MyCallback, 0);
  4532.   ┬╖
  4533.   ┬╖
  4534.   ┬╖
  4535.   SSRetUnsigned32 MyCallback( void* qpConsumer, void* qpBuff,
  4536.      SSUnsigned32 qulLen, void* qpParm)
  4537.      {
  4538.      /* Fill qpBuff with up to qpLen bytes */
  4539.      return /* Filled length or 0 for end of data */
  4540.      }
  4541.  
  4542.  
  4543. ΓòÉΓòÉΓòÉ 6.3.6. SSYacc ΓòÉΓòÉΓòÉ
  4544.  
  4545.  Concepts 
  4546.  SSYaccClearLastException 
  4547.  SSYaccCreate 
  4548.  SSYaccDestroy 
  4549.  SSYaccFreeValidLookaheads 
  4550.  SSYaccGetAbort 
  4551.  SSYaccGetElementFromProduction 
  4552.  SSYaccGetElementFromStack 
  4553.  SSYaccGetError 
  4554.  SSYaccGetLastException 
  4555.  SSYaccGetShiftedSinceError 
  4556.  SSYaccGetValidLookaheads 
  4557.  SSYaccParse 
  4558.  SSYaccProcessError 
  4559.  SSYaccReset 
  4560.  SSYaccSetAbort 
  4561.  SSYaccSetErrorCallback 
  4562.  SSYaccSetNextLexemeCallback 
  4563.  SSYaccSetShiftCallback 
  4564.  
  4565.  
  4566. ΓòÉΓòÉΓòÉ 6.3.6.1. Concepts ΓòÉΓòÉΓòÉ
  4567.  
  4568. The SSYacc functions create and control parsers. A parser requires two things 
  4569. to operate, a lexer (created with SSLexCreate), and a parse table (created with 
  4570. SSYaccTableCreate). 
  4571.  
  4572. There are four callback functions that you can use when writing a parser, the 
  4573. next lexeme callback, the shift callback, the reduce callback, and the error 
  4574. callback. 
  4575.  
  4576. The next lexeme callback (set with SSYaccSetNextLexemeCallback) is called when 
  4577. a lexeme is needed. The default callback gets the next lexeme from the lexer. 
  4578. Use this callback if you want to supply lexemes from your own source. The next 
  4579. lexeme callback is not required. 
  4580.  
  4581. The shift callback (set with SSYaccSetShiftCallback) is called when a lexeme is 
  4582. shifted on the stack. The default callback returns a stack element. The shift 
  4583. callback is not required. 
  4584.  
  4585. The reduce callback is called each time a production is reduced. A skeleton 
  4586. reduce callback is generated in the C header file for each rule file. This is 
  4587. where you put the application code for your parser. This callback is required 
  4588. on the SSYaccCreate function. 
  4589.  
  4590. The error callback (set with SSYaccSetErrorCallback) is called when a parsing 
  4591. error occurs. The default callback invokes the Visual Parse++ error recovery 
  4592. procedure (described in Error Recovery). Typically you will supply an error 
  4593. callback that will issue some type of diagnostic message, and then invoke 
  4594. SSYaccProcessError to attempt to recover from the error. 
  4595.  
  4596.  
  4597. ΓòÉΓòÉΓòÉ 6.3.6.2. SSYaccTableClearLastException ΓòÉΓòÉΓòÉ
  4598.  
  4599. The SSYaccClearLastException function clears any pending exceptions. 
  4600.  
  4601. Signature 
  4602.  
  4603. void SSYaccTableCreate( void*);
  4604.  
  4605.  Parameters          Meaning 
  4606.  
  4607.  void*               A parser correlator. 
  4608.  
  4609.  Example 
  4610.  
  4611.   SSYaccClearLastException( zpYacc);
  4612.  
  4613.  
  4614. ΓòÉΓòÉΓòÉ 6.3.6.3. SSYaccCreate ΓòÉΓòÉΓòÉ
  4615.  
  4616. The SSYaccCreate function creates a parser. Parsing is initiated with the 
  4617. SSYaccParse function. 
  4618.  
  4619. Signature 
  4620.  
  4621. void* SSYaccTableCreate( void*, void*, SSYaccReduceCallback,
  4622.    void*, SSUnsigned32, void**);
  4623.  
  4624.  Parameters          Meaning 
  4625.  
  4626.  void*               A lex correlator. 
  4627.  
  4628.  void*               A parse table correlator. 
  4629.  
  4630.  SSYaccReduceCallback The reduce callback address. The prototype is described 
  4631.                      below. 
  4632.  
  4633.  void*               A user parameter to pass to the reduce callback. 
  4634.  
  4635.  SSUnsigned32        The size of the user defined area that will be reserved in 
  4636.                      stack elements created by Visual Parse++. 
  4637.  
  4638.  void**              An address that is updated with an exception correlator if 
  4639.                      an exception occurs. 
  4640.  
  4641.  Returns 
  4642.  
  4643.  A parser correlator or 0. If zero is returned, examine the exception 
  4644.  correlator to determine the cause of the error. 
  4645.  
  4646.  The prototype of the reduce callback is: 
  4647.  
  4648.   void* reduce( void*, SSUnsigned32, SSUnsigned32, void*);
  4649.  
  4650.  Parameters          Meaning 
  4651.  
  4652.  void*               The parse correlator. 
  4653.  
  4654.  SSUnsigned32        The production number. 
  4655.  
  4656.  SSUnsigned32        The production size. 
  4657.  
  4658.  void*               The user parameter specified on SSYaccCreate. 
  4659.  
  4660.  Returns 
  4661.  
  4662.  A stack element correlator allocated with the SSYaccStackElementCreate 
  4663.  function. 
  4664.  
  4665.  Example 
  4666.  
  4667.  Assume zpLex and zpTable contain a lex correlator and a parse table 
  4668.  correlator, respectively. 
  4669.  
  4670.   void* zpYacc;
  4671.   void* zpException;
  4672.  
  4673.   zpYacc = SSYaccCreate( zpLex, zpTable, AReduceFunction, 0, 0, &zpException);
  4674.   if ( !zpYacc)
  4675.      {
  4676.      printf( "SSYaccCreate failed %s", SSExceptionGetMessage( zpException));
  4677.      return
  4678.   ┬╖
  4679.   ┬╖
  4680.   ┬╖
  4681.   SSRetVoidP AReduceFunction( void* qpYacc, SSUnsigned32 qulProd,
  4682.      SSUnsigned32 qulSize)
  4683.      {
  4684.      /* Process reduce */
  4685.   ┬╖
  4686.   ┬╖
  4687.   ┬╖
  4688.      return SSYaccStackElementCreate( 0, 0);
  4689.      }
  4690.  
  4691.  
  4692. ΓòÉΓòÉΓòÉ 6.3.6.4. SSYaccDestroy ΓòÉΓòÉΓòÉ
  4693.  
  4694. SSYaccDestroy destroys a parser. 
  4695.  
  4696. Signature 
  4697.  
  4698. void SSYaccDestroy( void*);
  4699.  
  4700.  Parameters          Meaning 
  4701.  
  4702.  void*               A parser correlator. 
  4703.  
  4704.  Example 
  4705.  
  4706.   SSYaccDestroy( zpYacc);
  4707.  
  4708.  
  4709. ΓòÉΓòÉΓòÉ 6.3.6.5. SSYaccFreeValidLookaheads ΓòÉΓòÉΓòÉ
  4710.  
  4711. SSYaccFreeValidLookaheads frees the valid lookahead array returned by 
  4712. SSYaccGetValidLookaheads 
  4713.  
  4714. Signature 
  4715.  
  4716. void SSYaccFreeValidLookaheads( SSUnsigned32*);
  4717.  
  4718.  Parameters          Meaning 
  4719.  
  4720.  SSUnsigned32*       A lookahead array address. 
  4721.  
  4722.  Example 
  4723.  
  4724.   SSYaccFreeValidLookaheads( zpulLook);
  4725.  
  4726.  
  4727. ΓòÉΓòÉΓòÉ 6.3.6.6. SSYaccGetAbort ΓòÉΓòÉΓòÉ
  4728.  
  4729. SSYaccGetAbort gets the abort code. The abort code is set with SSYaccSetAbort. 
  4730.  
  4731. Signature 
  4732.  
  4733. SSBooleanValue SSYaccGetAbort( void*);
  4734.  
  4735.  Parameters          Meaning 
  4736.  
  4737.  void*               A parse correlator. 
  4738.  
  4739.  Returns 
  4740.  
  4741.  SSTrue indicates that the parsing process was aborted with SSYaccSetAbort. 
  4742.  
  4743.  Example 
  4744.  
  4745.   SSBooleanValue zAbort = SSYaccGetAbort( zpYacc);
  4746.   if ( zAbort)
  4747.      {
  4748.      /* Parser aborted */
  4749.      }
  4750.  
  4751.  
  4752. ΓòÉΓòÉΓòÉ 6.3.6.7. SSYaccGetElementFromProduction ΓòÉΓòÉΓòÉ
  4753.  
  4754. SSYaccGetElementFromProduction gets a stack element. This function is only 
  4755. valid in a reduce callback. The element retrieved is relative to the current 
  4756. production being reduced. The index is 0 based, i.e., 0 will get the stack 
  4757. element associated with the first symbol on the right hand side of the 
  4758. production. 
  4759.  
  4760. Note 
  4761.  
  4762. A negative index can be used. 
  4763.  
  4764. Signature 
  4765.  
  4766. void* SSYaccGetElementFromProduction( void*, SSSigned32);
  4767.  
  4768.  Parameters          Meaning 
  4769.  
  4770.  void*               A parse correlator. 
  4771.  
  4772.  SSUnsigned32        The index. 
  4773.  
  4774.  Returns 
  4775.  
  4776.  A stack element correlator or 0. If zero, an invalid index was passed. 
  4777.  
  4778.  Example 
  4779.  
  4780.  Assume that the following example is a case statement in a reduce function, 
  4781.  and qpYacc contains a parse correlator. 
  4782.  
  4783.   case MyProd0:
  4784.   /* MyProd0 -> Symbol0 Symbol1 */
  4785.      {
  4786.      void* zpElement0;
  4787.      void* zpElement1;
  4788.  
  4789.      zpElement0 = SSYaccGetElementFromProduction( qpYacc, 0);
  4790.      zpElement1 = SSYaccGetElementFromProduction( qpYacc, 1);
  4791.      }
  4792.  
  4793.  
  4794. ΓòÉΓòÉΓòÉ 6.3.6.8. SSYaccGetElementFromStack ΓòÉΓòÉΓòÉ
  4795.  
  4796. SSYaccGetElementFromStack gets a stack element. The element retrieved is 
  4797. relative to the top of the stack. The top of the stack is index 0. 
  4798.  
  4799. Signature 
  4800.  
  4801. void* SSYaccGetElementFromStack( void*, SSUnsigned32);
  4802.  
  4803.  Parameters          Meaning 
  4804.  
  4805.  void*               A parse correlator. 
  4806.  
  4807.  SSUnsigned32        The index. 
  4808.  
  4809.  Returns 
  4810.  
  4811.  A stack element correlator or 0. If zero, an invalid index was passed. 
  4812.  
  4813.  Example 
  4814.  
  4815.  Assume that qpYacc contains a parse correlator. 
  4816.  
  4817.      void* zpElement0 = SSYaccGetElementFromStack( qpYacc, 0);
  4818.      /* Get the top stack element */
  4819.      }
  4820.  
  4821.  
  4822. ΓòÉΓòÉΓòÉ 6.3.6.9. SSYaccGetError ΓòÉΓòÉΓòÉ
  4823.  
  4824. SSYaccGetError gets the error code. The error code is set to SSTrue if a 
  4825. parsing error occurs. 
  4826.  
  4827. Note 
  4828.  
  4829. This is the same value returned by the SSYaccParse function. 
  4830.  
  4831. Signature 
  4832.  
  4833. SSBooleanValue SSYaccGetError( void*);
  4834.  
  4835.  Parameters          Meaning 
  4836.  
  4837.  void*               A parse correlator. 
  4838.  
  4839.  Returns 
  4840.  
  4841.  SSTrue indicates that the an error occurred. 
  4842.  
  4843.  Example 
  4844.  
  4845.   SSBooleanValue zError = SSYaccGetError( zpYacc);
  4846.   if ( zError)
  4847.      {
  4848.      /* Parser aborted */
  4849.      }
  4850.  
  4851.  
  4852. ΓòÉΓòÉΓòÉ 6.3.6.10. SSYaccGetLastException ΓòÉΓòÉΓòÉ
  4853.  
  4854. SSYaccGetLastException gets the last exception associated with the parser. 
  4855. Functions such as SSYaccParse and SSYaccProcessError can terminate and allocate 
  4856. an exception correlator which you can retrieve with this function. 
  4857.  
  4858. Note 
  4859.  
  4860. It is a good idea to check for pending exceptions after SSYaccParse has 
  4861. completed. 
  4862.  
  4863. Signature 
  4864.  
  4865. void* SSYaccGetLastException( void*);
  4866.  
  4867.  Parameters          Meaning 
  4868.  
  4869.  void*               A parse correlator. 
  4870.  
  4871.  Returns 
  4872.  
  4873.  An exception correlator or 0. Zero indicates there is no pending exception. 
  4874.  
  4875.  Example 
  4876.  
  4877.   void* zpException;
  4878.   SSYaccParse( zpYacc);
  4879.   zpException = SSYaccGetLastException( zpYacc);
  4880.   if ( zpException)
  4881.      printf( "Parse exception: %s\n", SSExceptionGetMessage( zpException));
  4882.  
  4883.  
  4884. ΓòÉΓòÉΓòÉ 6.3.6.11. SSYaccGetShiftedSinceError ΓòÉΓòÉΓòÉ
  4885.  
  4886. SSYaccGetShiftedSinceError gets the number of tokens shifted since the last 
  4887. error. It can be useful to check the number in your error callback to prevent 
  4888. cascading errors. If the number is not greater than say, three, you can abort 
  4889. the parse with SSYaccSetAbort. 
  4890.  
  4891. Signature 
  4892.  
  4893. SSUnsigned32 SSYaccGetShiftedSinceError( void*);
  4894.  
  4895.  Parameters          Meaning 
  4896.  
  4897.  void*               A parse correlator. 
  4898.  
  4899.  Returns 
  4900.  
  4901.  The number of tokens shifted since the last error. 
  4902.  
  4903.  Example 
  4904.  
  4905.   SSUnsigned32 zulShift = SSYaccGetShiftedSinceError( zpYacc);
  4906.  
  4907.  
  4908. ΓòÉΓòÉΓòÉ 6.3.6.12. SSYaccGetValidLookaheads ΓòÉΓòÉΓòÉ
  4909.  
  4910. SSYaccGetValidLookaheads returns an array of valid tokens given a state. This 
  4911. function, along with the xxxTokenToConstChar function generated in the header 
  4912. file, is useful for generating an error message. When an error occurs, the 
  4913. valid lookaheads for the error state can be obtained with this function. The 
  4914. token strings can be accessed with the xxxTokenToConstChar function to create 
  4915. an accurate diagnostic message. 
  4916.  
  4917. Signature 
  4918.  
  4919. SSUnsigned32* SSYaccGetValidLookaheads( void*, SSUnsigned32,
  4920.    SSUnsigned32*);
  4921.  
  4922.  Parameters          Meaning 
  4923.  
  4924.  void*               A parse correlator. 
  4925.  
  4926.  SSUnsigned32        A state. 
  4927.  
  4928.  SSUnsigned32*       A pointer to a value that will be updated with the number 
  4929.                      of tokens in the returned array. 
  4930.  
  4931.  Returns 
  4932.  
  4933.  The token array. 
  4934.  
  4935.  Example Assume qulState contains the state, and qpYacc contains the parser 
  4936.  correlator. The TokenToConstChar function name is prefixed with a user 
  4937.  specified string in the header file, but here, the name TokenToConstChar will 
  4938.  be used. 
  4939.  
  4940.   char achMsg[ 256];
  4941.   strcpy( achMsg, "Expected ");
  4942.   SSSigned32 zulLen = 255;
  4943.   zulLen -= strlen( "Expected ");
  4944.   SSUnsigned32 zulNum;
  4945.   SSUnsigned32* zpValid = SSYaccGetValidLookaheads( qpYacc, qulState, &zulNum);
  4946.   for ( int i = 0; i < zulNum; i++)
  4947.      {
  4948.      char* zpchToken = TokenToConstChar( zpValid[ i]);
  4949.      zlLen -= strlen( zpchToken);
  4950.      if ( zlLen <= 0) break;
  4951.      strcat( achMsg, zpchToken);
  4952.      if ( i < zulNum - 1)
  4953.         strcat( achMsg, ",");
  4954.      }
  4955.   SSYaccFreeValidLookaheads( zpValid);
  4956.  
  4957.  
  4958. ΓòÉΓòÉΓòÉ 6.3.6.13. SSYaccParse ΓòÉΓòÉΓòÉ
  4959.  
  4960. SSYaccParse starts the parsing process. The data is parsed, and the appropriate 
  4961. callbacks are invoked as events occur. 
  4962.  
  4963. Note 
  4964.  
  4965. It is a good idea to check for exceptions after parsing has completed. 
  4966.  
  4967. Signature 
  4968.  
  4969. SSBooleanValue SSYaccParse( void*);
  4970.  
  4971.  Parameters          Meaning 
  4972.  
  4973.  void*               A parse correlator. 
  4974.  
  4975.  Returns 
  4976.  
  4977.  SSTrue if an error occured while parsing. 
  4978.  
  4979.  Example 
  4980.  
  4981.   void* zpException;
  4982.   SSBooleanValue zParse = SSYaccParse( zpYacc);
  4983.   zpException = SSYaccGetLastException( zpYacc);
  4984.   if ( zParse || zpException)
  4985.      {
  4986.      printf( "Error during parse: %d\n", zParse);
  4987.      if ( zpException)
  4988.         printf( "Exception: %s\n", SSExceptionGetMessage( zpException));
  4989.      }
  4990.  
  4991.  
  4992. ΓòÉΓòÉΓòÉ 6.3.6.14. SSYaccProcessError ΓòÉΓòÉΓòÉ
  4993.  
  4994. SSYaccProcessError invokes Error Recovery. Usually, this function is called in 
  4995. the error callback after the error has been recorded. 
  4996.  
  4997. Signature 
  4998.  
  4999. SSBooleanValue SSYaccProcessError( void*);
  5000.  
  5001.  Parameters          Meaning 
  5002.  
  5003.  void*               A parse correlator. 
  5004.  
  5005.  Returns 
  5006.  
  5007.  SSTrue if an error occured while parsing. You can use SSYaccGetLastException 
  5008.  to get more information about the error. 
  5009.  
  5010.  Example 
  5011.  
  5012.  This is what a typical error callback looks like: 
  5013.  
  5014.   SSBooleanValue error( void* qpYacc, SSUnsigned32 qulState, void* qpLexeme)
  5015.      {
  5016.      /* Record error */
  5017.      return SSYaccProcessError( qpYacc);
  5018.      }
  5019.  
  5020.  
  5021. ΓòÉΓòÉΓòÉ 6.3.6.15. SSYaccReset ΓòÉΓòÉΓòÉ
  5022.  
  5023. SSYaccProcessReset resets the parser to its initial state. 
  5024.  
  5025. Signature 
  5026.  
  5027. void SSYaccReset( void*);
  5028.  
  5029.  Parameters          Meaning 
  5030.  
  5031.  void*               A parse correlator. 
  5032.  
  5033.  
  5034. ΓòÉΓòÉΓòÉ 6.3.6.16. SSYaccSetAbort ΓòÉΓòÉΓòÉ
  5035.  
  5036. SSYaccSetAbort aborts the parsing process. Use this function in a shift, error, 
  5037. or reduce callback to terminate parsing. 
  5038.  
  5039. Signature 
  5040.  
  5041. void SSYaccSetAbort( void*);
  5042.  
  5043.  Parameters          Meaning 
  5044.  
  5045.  void*               A parse correlator. 
  5046.  
  5047.  Example 
  5048.  
  5049.   SSYaccSetAbort( zpYacc);
  5050.  
  5051.  
  5052. ΓòÉΓòÉΓòÉ 6.3.6.17. SSYaccSetErrorCallback ΓòÉΓòÉΓòÉ
  5053.  
  5054. SSYaccSetErrorCallback sets the error callback. The error callback is invoked 
  5055. when a parsing error occurs. 
  5056.  
  5057. Signature 
  5058.  
  5059. void SSYaccSetErrorCallback( void*, SSYaccErrorCallback, void*);
  5060.  
  5061.  Parameters          Meaning 
  5062.  
  5063.  void*               A parse correlator. 
  5064.  
  5065.  SSYaccErrorCallback The callback address. The prototype is described below. 
  5066.  
  5067.  void*               A user parameter to pass to the callback. 
  5068.  
  5069.  This is the error callback prototype: 
  5070.  
  5071.   void* callback( void*, void*, SSUnsigned32, void*);
  5072.  
  5073.  Parameters          Meaning 
  5074.  
  5075.  void*               The parser correlator. 
  5076.  
  5077.  void*               The lexeme correlator of the lookahead symbol. 
  5078.  
  5079.  SSUnsigned32        The state. 
  5080.  
  5081.  void*               A user parameter specified on SSYaccSetErrorCallback. 
  5082.  
  5083.  Returns 
  5084.  
  5085.  SSTrue indicates that recovery failed, and parsing is to terminate. Usually, 
  5086.  you return the value of SSYaccProcessError, see the example below. 
  5087.  
  5088.  Example 
  5089.  
  5090.   SSYaccSetErrorCallback( zpYacc, MyCallback, 0);
  5091.   ┬╖
  5092.   ┬╖
  5093.   ┬╖
  5094.   SSRetVoidP MyCallback( void* qpYacc, void* qpLexeme,
  5095.      SSUnsigned32 qulState, void* qpParm)
  5096.      {
  5097.      /* Record error */
  5098.      return SSYaccProcessError( qpYacc);
  5099.      }
  5100.  
  5101.  
  5102. ΓòÉΓòÉΓòÉ 6.3.6.18. SSYaccSetNextLexemeCallback ΓòÉΓòÉΓòÉ
  5103.  
  5104. SSYaccSetNextLexemeCallback sets the next lexeme callback. The next lexeme 
  5105. callback is invoked when a lexeme is needed. This callback is only required if 
  5106. you want to get lexemes from a source other than a lexer. 
  5107.  
  5108. Signature 
  5109.  
  5110. void SSYaccSetNextLexemeCallback( void*, SSYaccNextLexemeCallback, void*);
  5111.  
  5112.  Parameters          Meaning 
  5113.  
  5114.  void*               A parse correlator. 
  5115.  
  5116.  SSYaccNextLexemeCallback The callback address. The prototype is described 
  5117.                      below. 
  5118.  
  5119.  void*               A user parameter to pass to the callback. 
  5120.  
  5121.  This is the next lexeme callback prototype: 
  5122.  
  5123.   void* callback( void*, void*);
  5124.  
  5125.  Parameters          Meaning 
  5126.  
  5127.  void*               The parser correlator. 
  5128.  
  5129.  void*               A user parameter specified on SSYaccSetNextLexemeCallback. 
  5130.  
  5131.  Returns 
  5132.  
  5133.  A lexeme correlator allocated with SSLexLexemeCreate. Zero indicates end of 
  5134.  data. 
  5135.  
  5136.  Example 
  5137.  
  5138.   SSYaccSetNextLexemeCallback( zpYacc, MyCallback, 0);
  5139.   ┬╖
  5140.   ┬╖
  5141.   ┬╖
  5142.   SSRetVoidP MyCallback( void* qpYacc, void* qpParm)
  5143.      {
  5144.      /* Set up SSLexLexemeCreate */
  5145.      if ( endOfData)
  5146.         return 0;
  5147.      else
  5148.         return SSLexLexemeCreate( ...
  5149.      }
  5150.  
  5151.  
  5152. ΓòÉΓòÉΓòÉ 6.3.6.19. SSYaccSetShiftCallback ΓòÉΓòÉΓòÉ
  5153.  
  5154. SSYaccSetShiftCallback sets the shift callback. The shift callback is invoked 
  5155. before each lexeme is shifted on the stack. 
  5156.  
  5157. Signature 
  5158.  
  5159. void SSYaccSetShiftCallback( void*, SSYaccShiftCallback, void*);
  5160.  
  5161.  Parameters          Meaning 
  5162.  
  5163.  void*               A parse correlator. 
  5164.  
  5165.  SSYaccShiftCallback The callback address. The prototype is described below. 
  5166.  
  5167.  void*               A user parameter to pass to the callback. 
  5168.  
  5169.  This is the shift callback prototype: 
  5170.  
  5171.   void* callback( void*, void*, void*);
  5172.  
  5173.  Parameters          Meaning 
  5174.  
  5175.  void*               The parser correlator. 
  5176.  
  5177.  void*               The lexeme correlator of the lexeme about to get shifted. 
  5178.  
  5179.  void*               A user parameter specified on SSYaccSetShiftCallback. 
  5180.  
  5181.  Returns 
  5182.  
  5183.  A stack element correlator allocated with SSYaccStackElementCreate. Zero 
  5184.  indicates that parsing should terminate. 
  5185.  
  5186.  Example 
  5187.  
  5188.   SSYaccSetShiftCallback( zpYacc, MyCallback, 0);
  5189.   ┬╖
  5190.   ┬╖
  5191.   ┬╖
  5192.   SSRetVoidP MyCallback( void* qpYacc, void* qpLexeme, void* qpParm)
  5193.      {
  5194.      void* zpElement = SSYaccStackElementCreate( 0, 0);
  5195.      /* Set up stack element */
  5196.      return zpElement;
  5197.      }
  5198.  
  5199.  
  5200. ΓòÉΓòÉΓòÉ 6.3.7. SSYaccTable ΓòÉΓòÉΓòÉ
  5201.  
  5202.  Concepts 
  5203.  SSYaccTableCreate 
  5204.  SSYaccTableDestroy 
  5205.  
  5206.  
  5207. ΓòÉΓòÉΓòÉ 6.3.7.1. Concepts ΓòÉΓòÉΓòÉ
  5208.  
  5209. The SSYaccTable functions create and destroy parser tables. They correspond to 
  5210. the C++ SSYaccTable class. 
  5211.  
  5212.  
  5213. ΓòÉΓòÉΓòÉ 6.3.7.2. SSYaccTableCreate ΓòÉΓòÉΓòÉ
  5214.  
  5215. The SSYaccTableCreate function creates a parser table. 
  5216.  
  5217. Signature 
  5218.  
  5219. void* SSYaccTableCreate( const char*, void**);
  5220.  
  5221.  Parameters          Meaning 
  5222.  
  5223.  const char*         The table name. 
  5224.  
  5225.  void**              An address that is updated with an exception correlator if 
  5226.                      an exception occurs. 
  5227.  
  5228.  Returns 
  5229.  
  5230.  A parse table correlator or 0. If zero is returned, examine the exception 
  5231.  correlator to determine the cause of the error. 
  5232.  
  5233.  Example 
  5234.  
  5235.   void* zpTable;
  5236.   void* zpException;
  5237.  
  5238.   zpTable = SSYaccTableCreate( "table.llr", &zpException);
  5239.   if ( !zpTable)
  5240.      printf( "SSYaccTableCreate failed %s", SSExceptionGetMessage( zpException));
  5241.  
  5242.  
  5243. ΓòÉΓòÉΓòÉ 6.3.7.3. SSYaccTableDestroy ΓòÉΓòÉΓòÉ
  5244.  
  5245. SSYaccTableDestroy destroys a parse table. 
  5246.  
  5247. Signature 
  5248.  
  5249. void SSYaccTableDestroy( void*);
  5250.  
  5251.  Parameters          Meaning 
  5252.  
  5253.  void*               A parse table correlator. 
  5254.  
  5255.  Example 
  5256.  
  5257.   SSYaccTableDestroy( zpTable);
  5258.  
  5259.  
  5260. ΓòÉΓòÉΓòÉ 6.3.8. SSYaccStackElement ΓòÉΓòÉΓòÉ
  5261.  
  5262.  Concepts 
  5263.  SSYaccStackElementCreate 
  5264.  SSYaccStackElementDestroy 
  5265.  SSYaccStackElementGetExtra 
  5266.  SSYaccStackElementGetLexeme 
  5267.  SSYaccStackElementGetState 
  5268.  SSYaccStackElementSetLexeme 
  5269.  SSYaccStackElementSetState 
  5270.  
  5271.  
  5272. ΓòÉΓòÉΓòÉ 6.3.8.1. Concepts ΓòÉΓòÉΓòÉ
  5273.  
  5274. The SSYaccStackElement functions create and provide access to parse stack 
  5275. elements. 
  5276.  
  5277.  
  5278. ΓòÉΓòÉΓòÉ 6.3.8.2. SSYaccStackElementCreate ΓòÉΓòÉΓòÉ
  5279.  
  5280. The SSYaccStackElementCreate function creates a stack element. This function is 
  5281. used in the shift or reduce callback to allocate and return a stack element. 
  5282.  
  5283. Signature 
  5284.  
  5285. void* SSYaccStackElementCreate( SSUnsigned32, void**);
  5286.  
  5287.  Parameters          Meaning 
  5288.  
  5289.  SSUnsigned32        The size of an area to reserve for the programmer's use. 
  5290.                      This area is retrieved with the SSYaccStackElementGetExtra 
  5291.                      function. 
  5292.  
  5293.  void**              An address that is updated with an exception correlator if 
  5294.                      an exception occurs. 
  5295.  
  5296.  Returns 
  5297.  
  5298.  A stack element correlator or 0. If zero is returned, examine the exception 
  5299.  correlator to determine the cause of the error. 
  5300.  
  5301.  Example 
  5302.  
  5303.   void* zpElement;
  5304.   void* zpException;
  5305.  
  5306.   /* Reserve 16 bytes in element */
  5307.   zpElement = SSYaccTableCreate( 16, &zpException);
  5308.   if ( !zpElement)
  5309.      printf( "SSYaccStackElementCreate failed %s",
  5310.         SSExceptionGetMessage( zpException));
  5311.  
  5312.  
  5313. ΓòÉΓòÉΓòÉ 6.3.8.3. SSYaccStackElementDestroy ΓòÉΓòÉΓòÉ
  5314.  
  5315. SSYaccStackElementDestroy destroys a stack element. Use this function with 
  5316. extreme caution, if at all. Stack elements are shared between Visual Parse++ 
  5317. and your application code, destroying a stack element may release an element 
  5318. that is currently in use. Normally, Visual Parse++ destroys stack elements. 
  5319.  
  5320. Signature 
  5321.  
  5322. void SSYaccStackElementDestroy( void*);
  5323.  
  5324.  Parameters          Meaning 
  5325.  
  5326.  void*               A stack element correlator. 
  5327.  
  5328.  
  5329. ΓòÉΓòÉΓòÉ 6.3.8.4. SSYaccStackElementGetExtra ΓòÉΓòÉΓòÉ
  5330.  
  5331. SSYaccStackElementGetExtra returns the address of the area in the stack element 
  5332. reserved for the programmer's use. This size of this area was specified with 
  5333. SSYaccStackElementCreate. 
  5334.  
  5335. Signature 
  5336.  
  5337. void* SSYaccStackElementGetExtra( void*);
  5338.  
  5339.  Parameters          Meaning 
  5340.  
  5341.  void*               A stack element correlator. 
  5342.  
  5343.  Returns 
  5344.  
  5345.  A pointer to the reserved area. 
  5346.  
  5347.  Example 
  5348.  
  5349.   void* zpArea = SSYaccStackElementGetExtra( zpElement);
  5350.  
  5351.  
  5352. ΓòÉΓòÉΓòÉ 6.3.8.5. SSYaccStackElementGetLexeme ΓòÉΓòÉΓòÉ
  5353.  
  5354. SSYaccStackElementGetLexeme returns the lexeme correlator associated with the 
  5355. stack element. 
  5356.  
  5357. Signature 
  5358.  
  5359. void* SSYaccStackElementGetLexeme( void*);
  5360.  
  5361.  Parameters          Meaning 
  5362.  
  5363.  void*               A stack element correlator. 
  5364.  
  5365.  Returns 
  5366.  
  5367.  A lexeme correlator or 0. Zero indicates that there is no lexeme associated 
  5368.  with this stack element. 
  5369.  
  5370.  Example 
  5371.  
  5372.   void* zpLexeme = SSYaccStackElementGetLexeme( zpElement);
  5373.  
  5374.  
  5375. ΓòÉΓòÉΓòÉ 6.3.8.6. SSYaccStackElementGetState ΓòÉΓòÉΓòÉ
  5376.  
  5377. SSYaccStackElementGetState returns the state associated with the stack element. 
  5378.  
  5379. Signature 
  5380.  
  5381. SSUnsigned32 SSYaccStackElementGetState( void*);
  5382.  
  5383.  Parameters          Meaning 
  5384.  
  5385.  void*               A stack element correlator. 
  5386.  
  5387.  Returns 
  5388.  
  5389.  A state associated with the lexeme. 
  5390.  
  5391.  Example 
  5392.  
  5393.   SSUnsigned32 zulState = SSYaccStackElementGetState( zpElement);
  5394.  
  5395.  
  5396. ΓòÉΓòÉΓòÉ 6.3.8.7. SSYaccStackElementSetLexeme ΓòÉΓòÉΓòÉ
  5397.  
  5398. SSYaccStackElementSetLexeme sets the lexeme associated with the stack element. 
  5399.  
  5400. Signature 
  5401.  
  5402. void SSYaccStackElementSetLexeme( void*, void*);
  5403.  
  5404.  Parameters          Meaning 
  5405.  
  5406.  void*               A stack element correlator. 
  5407.  
  5408.  void*               A lexeme correlator. 
  5409.  
  5410.  Example 
  5411.  
  5412.   SSYaccStackElementSetLexeme( zpElement, zpLexeme);
  5413.  
  5414.  
  5415. ΓòÉΓòÉΓòÉ 6.3.8.8. SSYaccStackElementSetState ΓòÉΓòÉΓòÉ
  5416.  
  5417. SSYaccStackElementSetState sets the state associated with the stack element. 
  5418. Use this function with extreme caution, if at all. The state contained in a 
  5419. stack element is crucial to the parsing process. 
  5420.  
  5421. Signature 
  5422.  
  5423. void SSYaccStackElementSetState( void*, SSUnsigned32);
  5424.  
  5425.  Parameters          Meaning 
  5426.  
  5427.  void*               A stack element correlator. 
  5428.  
  5429.  SSUnsigned32        The state. 
  5430.  
  5431.  
  5432. ΓòÉΓòÉΓòÉ 6.3.9. SSException ΓòÉΓòÉΓòÉ
  5433.  
  5434.  Concepts 
  5435.  SSExceptionDestroy 
  5436.  SSExceptionGetErrorId 
  5437.  SSExceptionGetMessage 
  5438.  SSExceptionSetBadCorrelatorCallback 
  5439.  
  5440.  
  5441. ΓòÉΓòÉΓòÉ 6.3.9.1. Concepts ΓòÉΓòÉΓòÉ
  5442.  
  5443. The SSException functions get information related to exception correlators. 
  5444. Exception correlators are created by Visual Parse++ when errors occur. 
  5445.  
  5446. The function SSExceptionSetBadCorrelatorCallback sets a user defined function 
  5447. that is invoked when a bad correlator is detected. The default bad correlator 
  5448. callback issues an abort. Override this function if you want to issue a 
  5449. disgnostic message before aborting. 
  5450.  
  5451.  
  5452. ΓòÉΓòÉΓòÉ 6.3.9.2. SSExceptionDestroy ΓòÉΓòÉΓòÉ
  5453.  
  5454. SSExceptionDestroy destroys an exception correlator. 
  5455.  
  5456. Signature 
  5457.  
  5458. void SSExceptionDestroy( void*);
  5459.  
  5460.  Parameters          Meaning 
  5461.  
  5462.  void*               An exception correlator. 
  5463.  
  5464.   SSExceptionDestroy( zpException);
  5465.  
  5466.  
  5467. ΓòÉΓòÉΓòÉ 6.3.9.3. SSExceptionGetErrorId ΓòÉΓòÉΓòÉ
  5468.  
  5469. SSExceptionGetErrorId returns the error id for the exception. 
  5470.  
  5471. Signature 
  5472.  
  5473. SSUnsigned32 SSExceptionGetErrorId( void*);
  5474.  
  5475.  Parameters          Meaning 
  5476.  
  5477.  void*               An exception correlator. 
  5478.  
  5479.  Returns 
  5480.  
  5481.  The error id. 
  5482.  
  5483.  Example 
  5484.  
  5485.   SSUnsigned32 zulId = SSExceptionGetErrorId( zpException);
  5486.  
  5487.  
  5488. ΓòÉΓòÉΓòÉ 6.3.9.4. SSExceptionGetMessage ΓòÉΓòÉΓòÉ
  5489.  
  5490. SSExceptionGetMessage returns the message for the exception. 
  5491.  
  5492. Signature 
  5493.  
  5494. const char* SSExceptionGetMessage( void*);
  5495.  
  5496.  Parameters          Meaning 
  5497.  
  5498.  void*               An exception correlator. 
  5499.  
  5500.  Returns 
  5501.  
  5502.  The error message. 
  5503.  
  5504.  Example 
  5505.  
  5506.   const char* zpszMsg = SSExceptionGetMessage( zpException);
  5507.  
  5508.  
  5509. ΓòÉΓòÉΓòÉ 6.3.9.5. SSExceptionSetBadCorrelatorCallback ΓòÉΓòÉΓòÉ
  5510.  
  5511. SSExceptionSetBadCorrelatorCallback sets the bad correlator callback. The 
  5512. callback is invoked when a bad correlator is detected. 
  5513.  
  5514. Signature 
  5515.  
  5516. void SSExceptionSetBadCorrelatorCallback(
  5517.    SSExceptionBadCorrelatorCallback, void*);
  5518.  
  5519.  Parameters          Meaning 
  5520.  
  5521.  SSExceptionBadCorrelatorCallback The function address. The prototype is: 
  5522.  
  5523.   void callback( void*, const char*, void*);
  5524.  
  5525.  Parameters          Meaning 
  5526.  
  5527.  void*               The bad correlator. 
  5528.  
  5529.  const char*         A 4 character correlator id, indicating which correlator 
  5530.                      was invalid. These are the valid id's: 
  5531.  
  5532.     SSEX  An exception correlator. 
  5533.  
  5534.     SSLT  An lex table correlator. 
  5535.  
  5536.     SSCO  An consumer correlator. 
  5537.  
  5538.     SSLM  An lexeme correlator. 
  5539.  
  5540.     SSLX  An lex correlator. 
  5541.  
  5542.     SSYT  An parse table correlator. 
  5543.  
  5544.     SSSE  An stack element correlator. 
  5545.  
  5546.     SSYC  An parse correlator. 
  5547.  
  5548.  void*               The user parameter passed when setting the callback. 
  5549.  
  5550.  Example 
  5551.  
  5552.   SSExceptionSetBadCorrelatorCallback( MyCallback, 0);
  5553.   ┬╖
  5554.   ┬╖
  5555.   ┬╖
  5556.   SSRetVoid MyCallback( void* qpCorr, const char* qpchId, void* qpParm)
  5557.      {
  5558.      printf( "Bad correlator: %.4s\n", qpchId);
  5559.  
  5560.  
  5561. ΓòÉΓòÉΓòÉ 6.4. REXX ΓòÉΓòÉΓòÉ
  5562.  
  5563.  Concepts 
  5564.  SSLex 
  5565.  SSYacc 
  5566.  
  5567.  
  5568. ΓòÉΓòÉΓòÉ 6.4.1. Concepts ΓòÉΓòÉΓòÉ
  5569.  
  5570. The REXX functions allow you to write a complete parser in REXX. This can be 
  5571. very useful, due to the string-oriented nature of REXX, and the fact that the 
  5572. REXX supplied parsing functions are very weak. 
  5573.  
  5574. The REXX bindings depart from the parser/callback or object/virtual function 
  5575. architecture of the C and C++ bindings. This is beacuse of some limitations in 
  5576. REXX related to variable pools, i.e., they are not shared. 
  5577.  
  5578. What this means to you, the programmer, is nothing. Instead of the common code 
  5579. being hidden in a library as in C or C++, you see and have access to the REXX 
  5580. code that performs the same function. Except under unusual circumstances, you 
  5581. should never have to concern yourself with the details. 
  5582.  
  5583. As usual, the main function of interest is the reduce function generated by 
  5584. Visual Parse++. This is where you put your application code to process the 
  5585. reductions as they occur, and is about the only area in the REXX file that you 
  5586. will make any changes (other than on SSLexCreate, which specifies the data that 
  5587. is to be parsed). 
  5588.  
  5589. Like the C functions, the REXX Create functions return a correlator or handle 
  5590. which is used on subsequent function calls to request services. A bad 
  5591. correlator will cause a return code 40, which drives the 'on syntax' signal. 
  5592. The skeleton parser generated by Visual Parse++ contains appropriate signal 
  5593. handling to catch this case and issue an error message. Other errors are 
  5594. indicated in the same way. For all errors, the SSRESULT variable is updated 
  5595. with a detailed error message. 
  5596.  
  5597.  
  5598. ΓòÉΓòÉΓòÉ 6.4.2. SSLex ΓòÉΓòÉΓòÉ
  5599.  
  5600.  Concepts 
  5601.  SSLexAddData 
  5602.  SSLexCreate 
  5603.  SSLexGetNextLexeme 
  5604.  SSLexDestroy 
  5605.  
  5606.  
  5607. ΓòÉΓòÉΓòÉ 6.4.2.1. Concepts ΓòÉΓòÉΓòÉ
  5608.  
  5609. The SSLex functions create and control lexical analyzers. 
  5610.  
  5611.  
  5612. ΓòÉΓòÉΓòÉ 6.4.2.2. SSLexAddData ΓòÉΓòÉΓòÉ
  5613.  
  5614. SSLexAddData adds data to a lexical analyzer. This function is only valid when 
  5615. SSMORE is returned by either the SSLexGetNextLexeme or SSYaccParse function. 
  5616. The data specified is added to the lexer's internal buffer. If you do not add 
  5617. data in response to SSMORE, end of data is assumed. 
  5618.  
  5619. Signature 
  5620.  
  5621. ok SSLexAddData( lexCorrelator, data)
  5622.  
  5623.  Parameters          Meaning 
  5624.  
  5625.  lexCorrelator       The lex correlator returned by SSLexCreate. 
  5626.  
  5627.  data                The data to add to the buffer. 
  5628.  
  5629.  Returns 
  5630.  
  5631.  Normally, SSOK. The syntax signal handler is driven if an error occurs. The 
  5632.  variable SSRESULT is updated with the reason for the failure. 
  5633.  
  5634.  Example 
  5635.  
  5636.   ret = SSLexAddData( lexCorr, 'new data')
  5637.  
  5638.  
  5639. ΓòÉΓòÉΓòÉ 6.4.2.3. SSLexCreate ΓòÉΓòÉΓòÉ
  5640.  
  5641. SSLexCreate creates a lexical analyzer. 
  5642.  
  5643. Signature 
  5644.  
  5645. lexCorr SSLexCreate( varTable, varConsumer, type)
  5646.  
  5647.  Parameters          Meaning 
  5648.  
  5649.  varTable            The lex table name. 
  5650.  
  5651.  varConsumer         Either a file name or data, see the type parameter. 
  5652.  
  5653.  type                The consumer type, one of SSFILE, SSQUERY, or SSBUFFER. 
  5654.                      SSFILE indicates that varConsumer contains a file name. 
  5655.                      SSQUERY means that varConsumer contains data, and that the 
  5656.                      SSMORE return code is to br returned from SSYaccParse when 
  5657.                      more data is needed. SSBUFFER indicates that varConsumer 
  5658.                      contains a single string of data. The SSMORE return code 
  5659.                      is never returned if SSBUFFER or SSFILE is specified. 
  5660.  
  5661.  Returns 
  5662.  
  5663.  The lex correlator. The syntax signal handler is driven if an error occurs. 
  5664.  The variable SSRESULT is updated with the reason for the failure. 
  5665.  
  5666.  Example 
  5667.  
  5668.   lexCorr = SSLexCreate( 'table.dfa', 'file.name', SSFILE)
  5669.  
  5670.  
  5671. ΓòÉΓòÉΓòÉ 6.4.2.4. SSLexGetNextLexeme ΓòÉΓòÉΓòÉ
  5672.  
  5673. SSLexGetNextLexeme retrieves lexemes. This function is used as the driver for 
  5674. standalone lexical analyzers, similar to the way SSYaccParse is used. The 
  5675. driver code is generated by Visual Parse++ for rule files that do not contain a 
  5676. %production section. The driver code looks like: 
  5677.  
  5678. do forever
  5679.    SSRet = SSLexGetNextLexeme( lexCorr, SSParm)
  5680.    select
  5681.       when SSRet = SSOK then
  5682.          /* Lexeme returned */
  5683.       when SSRet = SSDONE then
  5684.          /* Finished */
  5685.          leave
  5686.       when SSRet = SSMORE then
  5687.          /* Get more data */
  5688.       when SSRet = SSLEXERROR
  5689.          /* Invalid lexeme */
  5690.    end
  5691. end
  5692.  
  5693. SSOK indicates that a lexeme has been recognized. The stem variable (SSParm in 
  5694. this case) is used as a compound variable stem to return the lexeme parameters. 
  5695. A lexeme has four parameters: 
  5696.  
  5697.  var.0     The lexeme. 
  5698.  
  5699.  var.1     The token number. 
  5700.  
  5701.  var.2     The line number. 
  5702.  
  5703.  var.3     The line offset. 
  5704.  
  5705.  SSDONE means lexing is finished, and the do loop is exited. 
  5706.  
  5707.  SSMORE indicates that more data is needed. If you reissue SSLexGetNextLexeme 
  5708.  without issuing the SSLexAddData function, end of data is assumed. 
  5709.  
  5710.  SSLEXERROR indicates an invalid lexeme was detected. The lexeme parameters are 
  5711.  returned, but the token index (index 1) is invalid, because the token could 
  5712.  not be determined. If you continue, the lexeme is discarded. 
  5713.  
  5714.  Signature 
  5715.  
  5716.   ret SSLexGetNextLexeme( lexCorrelator, stem)
  5717.  
  5718.  Parameters          Meaning 
  5719.  
  5720.  lexCorrelator       The lex correlator returned by SSLexCreate. 
  5721.  
  5722.  stem                The stem used to construct the returned compound 
  5723.                      variables. 
  5724.  
  5725.  Returns 
  5726.  
  5727.  Normally, SSOK. The syntax signal handler is driven if an error occurs. The 
  5728.  variable SSRESULT is updated with the reason for the failure. 
  5729.  
  5730.  
  5731. ΓòÉΓòÉΓòÉ 6.4.2.5. SSLexDestroy ΓòÉΓòÉΓòÉ
  5732.  
  5733. SSLexDestroy destroys a lexical analyzer. 
  5734.  
  5735. Signature 
  5736.  
  5737. ok SSLexDestroy( lexCorrelator)
  5738.  
  5739.  Parameters          Meaning 
  5740.  
  5741.  lexCorrelator       The lex correlator. 
  5742.  
  5743.  Returns 
  5744.  
  5745.  Normally SSOK. The syntax signal handler is driven if an error occurs. The 
  5746.  variable SSRESULT is updated with the reason for the failure. 
  5747.  
  5748.  Example 
  5749.  
  5750.   ret = SSLexDestroy( lexCorr)
  5751.  
  5752.  
  5753. ΓòÉΓòÉΓòÉ 6.4.3. SSYacc ΓòÉΓòÉΓòÉ
  5754.  
  5755.  Concepts 
  5756.  SSYaccChangeToken 
  5757.  SSYaccCreate 
  5758.  SSYaccDestroy 
  5759.  SSYaccGetStackParmsFromProduction 
  5760.  SSYaccParse 
  5761.  SSYaccSetStackParm 
  5762.  
  5763.  
  5764. ΓòÉΓòÉΓòÉ 6.4.3.1. Concepts ΓòÉΓòÉΓòÉ
  5765.  
  5766. The SSYacc functions create and control parsers. 
  5767.  
  5768.  
  5769. ΓòÉΓòÉΓòÉ 6.4.3.2. SSYaccChangeToken ΓòÉΓòÉΓòÉ
  5770.  
  5771. SSYaccChangeToken is used to change a token number in a lexeme before it is 
  5772. passed to the parser for processing. This function is only valid when SSOK is 
  5773. returned from SSYaccParse. SSOK is returned when a lexeme is recognized, but 
  5774. before it is passed to the parser. 
  5775.  
  5776. Signature 
  5777.  
  5778. ok SSYaccChangeToken( parseCorrelator, token)
  5779.  
  5780.  Parameters          Meaning 
  5781.  
  5782.  parseCorrelator     The parser correlator returned by SSYaccCreate. 
  5783.  
  5784.  token               The new token number. 
  5785.  
  5786.  Returns 
  5787.  
  5788.  Normally, SSOK. The syntax signal handler is driven if an error occurs. The 
  5789.  variable SSRESULT is updated with the reason for the failure. 
  5790.  
  5791.  Example 
  5792.  
  5793.   ret = SSYaccChangeToken( parseCorr, 23)
  5794.  
  5795.  
  5796. ΓòÉΓòÉΓòÉ 6.4.3.3. SSYaccCreate ΓòÉΓòÉΓòÉ
  5797.  
  5798. SSYaccCreate creates a parser. 
  5799.  
  5800. Signature 
  5801.  
  5802. parseCorr SSYaccCreate( lexCorr, table)
  5803.  
  5804.  Parameters          Meaning 
  5805.  
  5806.  lexCorr             A lex correlator. 
  5807.  
  5808.  varTable            The parse table name. 
  5809.  
  5810.  Returns 
  5811.  
  5812.  The parse correlator. The syntax signal handler is driven if an error occurs. 
  5813.  The variable SSRESULT is updated with the reason for the failure. 
  5814.  
  5815.  Example 
  5816.  
  5817.   parseCorr = SSYaccCreate( lexCorr, 'table.llr')
  5818.  
  5819.  
  5820. ΓòÉΓòÉΓòÉ 6.4.3.4. SSYaccDestroy ΓòÉΓòÉΓòÉ
  5821.  
  5822. SSYaccDestory destroys a parser. 
  5823.  
  5824. Signature 
  5825.  
  5826. ok SSYaccDestroy( parseCorr)
  5827.  
  5828.  Parameters          Meaning 
  5829.  
  5830.  parseCorr           A parse correlator. 
  5831.  
  5832.  Returns 
  5833.  
  5834.  Normally, SSOK. The syntax signal handler is driven if an error occurs. The 
  5835.  variable SSRESULT is updated with the reason for the failure. 
  5836.  
  5837.  Example 
  5838.  
  5839.   ret = SSYaccDestroy( parseCorr)
  5840.  
  5841.  
  5842. ΓòÉΓòÉΓòÉ 6.4.3.5. SSYaccGetStackParmsFromProduction ΓòÉΓòÉΓòÉ
  5843.  
  5844. SSYaccGetStackParmsFromProduction retrieves the stack parameters associated 
  5845. with the supplied production index. This function is only valid in the reduce 
  5846. internal function generated by Visual Parse++. 
  5847.  
  5848. The index refers to a symbol in the production, and is 0 based (0 is the first 
  5849. symbol on the righthand side). 
  5850.  
  5851. The variable stem is used to construct compound variables containing the stack 
  5852. parameters. The variables are: 
  5853.  
  5854.  var.0     The lexeme. 
  5855.  
  5856.  var.1     The token number. 
  5857.  
  5858.  var.2     The line number. 
  5859.  
  5860.  var.3     The line offset. 
  5861.  
  5862.  var.4     The stack parameter. 
  5863.  
  5864.  Note that indices 0-3 are the lexeme parameters returned on the SSYaccParse 
  5865.  and SSLexGetNextLexeme functions. The stack parameter is passed from a 
  5866.  previous reduction and is set with the SSYaccSetStackParm function. 
  5867.  
  5868.  Signature 
  5869.  
  5870.   ok SSYaccGetStackParmsFromProduction( parseCorr, index, stem)
  5871.  
  5872.  Parameters          Meaning 
  5873.  
  5874.  parseCorr           A parser correlator. 
  5875.  
  5876.  index               The production index. 
  5877.  
  5878.  stem                The variable stem used to construct the returned compound 
  5879.                      variables. 
  5880.  
  5881.  Returns 
  5882.  
  5883.  Normally SSOK. The syntax signal handler is driven if an error occurs. The 
  5884.  variable SSRESULT is updated with the reason for the failure. 
  5885.  
  5886.  Example 
  5887.  
  5888.  For a detailed example, see sscalcrx.cmd in \SAMPLES\SSCALC. 
  5889.  
  5890.   ret = SSYaccGetStackParmsFromProduction( parseCorr, 0, SSParm)
  5891.  
  5892.  
  5893. ΓòÉΓòÉΓòÉ 6.4.3.6. SSYaccParse ΓòÉΓòÉΓòÉ
  5894.  
  5895. SSYaccParse invokes the parser. This function is the driver for the parsing 
  5896. process. The return values from SSYaccParse indicate which action to take. You 
  5897. can view parser drivers in any Visual Parse++ generated REXX file. The parser 
  5898. driver looks like: 
  5899.  
  5900. do forever
  5901.    SSRet = SSYaccParse( parseCorr, SSParm)
  5902.    select
  5903.       when SSRet = SSOK then
  5904.          /* Lexeme recognized */
  5905.       when SSRet = SSMORE then
  5906.          /* Get more data */
  5907.       when SSRet = SSSHIFT then
  5908.          /* Shift occurred */
  5909.       when SSRet = SSREDUCE then
  5910.          /* Process reduce */
  5911.       when SSRet = SSACCEPT then
  5912.          /* Accepted */
  5913.       when SSRet = SSLEXERROR then
  5914.          /* Lexeme error */
  5915.       when SSRet = SSYACCERROR then
  5916.          /* Parse error */
  5917.    end
  5918. end
  5919.  
  5920. SSOK indicates that a lexeme has been recognized. The stem is used to construct 
  5921. compound variables that contain the lexeme parameters. The variables are: 
  5922.  
  5923.  var.0     The lexeme. 
  5924.  
  5925.  var.1     The token number. 
  5926.  
  5927.  var.2     The line number. 
  5928.  
  5929.  var.3     The line offset. 
  5930.  
  5931.  SSMORE indicates that more data is needed. You will only get this return value 
  5932.  if the SSLexCreate function used the SSQUERY parameter. You can add data with 
  5933.  the SSLexAddData function. If no data is added, end of data is assumed. 
  5934.  
  5935.  SSSHIFT is returned when a token is shifted on the stack. The lexeme 
  5936.  parameters are returned as with SSOK. 
  5937.  
  5938.  SSREDUCE is returned when a reduction is taking place. The internal reduce 
  5939.  subroutine, generated by Visual Parse++, is called to process the reduction. 
  5940.  
  5941.  SSLEXERROR indicates that an invalid lexeme was detected. The variables 
  5942.  mentioned in the SSOK section are updated with the lexeme parameters, but the 
  5943.  token number is not valid, because it could not be determined. If you 
  5944.  continue, the lexeme is ignored. 
  5945.  
  5946.  SSYACCERROR is returned when a parsing error occurs. If you continue, an 
  5947.  attempt to recover is made. If recovery fails, SSPERMERROR is returned. 
  5948.  
  5949.  SSPERMERROR indicates that a permanent error has occurred. Usually, this is 
  5950.  the result of an unrecoverable parsing error. Any additional processing 
  5951.  results in SSPERMERROR return values. 
  5952.  
  5953.  Signature 
  5954.  
  5955.   ret SSYaccParse( parseCorr, stem)
  5956.  
  5957.  Parameters          Meaning 
  5958.  
  5959.  parseCorr           A parse correlator. 
  5960.  
  5961.  stem                A compound variable stem. 
  5962.  
  5963.  Returns 
  5964.  
  5965.  See the description above for possible return values. The syntax signal 
  5966.  handler is driven if an error occurs. The variable SSRESULT is updated with 
  5967.  the reason for the failure. 
  5968.  
  5969.  Example 
  5970.  
  5971.  See any Visual Parse++ generated file. 
  5972.  
  5973.  
  5974. ΓòÉΓòÉΓòÉ 6.4.3.7. SSYaccSetStackParm ΓòÉΓòÉΓòÉ
  5975.  
  5976. SSYaccSetStackParm sets the stack parameter that is pushed on the stack as a 
  5977. result of a reduction. This function is only valid when SSREDUCE is returned by 
  5978. SSYaccParse, in the reduce internal function generated by Visual Parse++. The 
  5979. stack parameter is pushed on the stack after the righthand side of the 
  5980. production is popped (this is what a reduction does). The stack parameter is 
  5981. retrieved with the SSYaccGetStackParmsFromProduction function. 
  5982.  
  5983. Signature 
  5984.  
  5985. ok SSYaccSetStackParm( parseCorr, parm)
  5986.  
  5987.  Parameters          Meaning 
  5988.  
  5989.  parseCorr           A parse correlator. 
  5990.  
  5991.  parm                The parameter. 
  5992.  
  5993.  Returns 
  5994.  
  5995.  Normally, SSOK. The syntax signal handler is driven if an error occurs. The 
  5996.  variable SSRESULT is updated with the reason for the failure. 
  5997.  
  5998.  Example 
  5999.  
  6000.  For a detailed example, see sscalcrx.cmd in \SAMPLES\SSCALC. 
  6001.  
  6002.   ret = SSYaccSetStackParm( parseCorr, 'some parameter')
  6003.  
  6004.  
  6005. ΓòÉΓòÉΓòÉ 7. Command Line Parser ΓòÉΓòÉΓòÉ
  6006.  
  6007.  Concepts 
  6008.  C++ Bindings 
  6009.  C Bindings 
  6010.  
  6011.  
  6012. ΓòÉΓòÉΓòÉ 7.1. Concepts ΓòÉΓòÉΓòÉ
  6013.  
  6014. The command line parser provides a set of easy to use services to parse a 
  6015. command line. C and C++ bindings are provided. The syntax of a command line 
  6016. accepted by the supplied bindings is: 
  6017.  
  6018. command [ options ] list, ...
  6019.  
  6020.  Parameter      Meaning 
  6021.  
  6022.  command        The command name. 
  6023.  
  6024.  options        The options. 
  6025.  
  6026.  parameter      A list of parameters. 
  6027.  
  6028.  Each option has syntax: 
  6029.  
  6030.   (-|/)option[ (+|-) ][ ]parameter
  6031.  
  6032.  In words, options are preceded by either a '-' or a '/' and followed by an 
  6033.  optional '+' or '-'.  If the '+' or '-' is missing, '+' is assumed. If the 
  6034.  parameter is optional, it must be concatenated on the end of the option string 
  6035.  (without the '+' sign). If it is required, there can be intervening white 
  6036.  space. 
  6037.  
  6038.  An arbitrary number of parameters can follow the options. 
  6039.  
  6040.  Note This is the same syntax that the Visual Parse++ commands accept. 
  6041.  
  6042.  Two options are added by the bindings, the /H and /P options. 
  6043.  
  6044.  The /H (help)  option prints a list of valid options based on information 
  6045.  supplied through the bindings. As you specify options with the bindings 
  6046.  (described later), you supply a description. The /H option writes this 
  6047.  information to either stdout or a programmer supplied file name. The output 
  6048.  looks like: 
  6049.  
  6050.   command [options] parms
  6051.  
  6052.      -Opt1   Opt1 Description
  6053.      -Opt2   Opt2 Description
  6054.      -Opt3   Opt3 Description
  6055.      ┬╖
  6056.      ┬╖
  6057.      ┬╖
  6058.  
  6059.  The /P (print) option prints a list of the options that were specified on the 
  6060.  command line. The output goes to stdout or a programmer supplied file name. 
  6061.  The output looks like: 
  6062.  
  6063.   command
  6064.  
  6065.      -Opt1  Opt(0 or 1) Parm(parm)
  6066.      -Opt2  Opt(0 or 1) Parm(parm)
  6067.      -Opt3  Opt(0 or 1) Parm(parm)
  6068.      ┬╖
  6069.      ┬╖
  6070.      ┬╖
  6071.      Parm(parm1)
  6072.      Parm(parm2)
  6073.      Parm(parm3)
  6074.      ┬╖
  6075.      ┬╖
  6076.      ┬╖
  6077.  
  6078.  The Opt field gives the - (0) or + (1) information, and the Parm field shows 
  6079.  the parameters associated with the option (if any). The options list is 
  6080.  followed by the list of parameters specified on the command. 
  6081.  
  6082.  
  6083. ΓòÉΓòÉΓòÉ 7.2. C++ Bindings ΓòÉΓòÉΓòÉ
  6084.  
  6085.  Concepts 
  6086.  SSComlin 
  6087.  SSComlinOption 
  6088.  
  6089.  
  6090. ΓòÉΓòÉΓòÉ 7.2.1. Concepts ΓòÉΓòÉΓòÉ
  6091.  
  6092. The command line C++ bindings provide an easy to use interface for parsing a 
  6093. command line. There are two classes of interest, SSComlin and SSComlinOption. 
  6094.  
  6095. SSComlin is the command line anchor to which SSComlinOption instances are 
  6096. attached. After attaching all the options, the parse member function is invoked 
  6097. to process the command line. SSComlin and SSComlinOption member functions are 
  6098. provided to retrieve the paramters associated with the options, and determining 
  6099. option characteristics (like if the option was specified). 
  6100.  
  6101. Here is a small example that parses a command line expecting options 'A', 'B', 
  6102. and 'C': 
  6103.  
  6104. #include<sscomlin.hpp>
  6105. int main( int qiArg, char** qapszArg)
  6106.    {
  6107.    SSComlin zCom( "Command", qiArg, qapszArg, "Desc", 0, 0);
  6108.    SSComlinOption zOptA( zCom, "A", "A Desc", SSFalse, SSComlinOption::none);
  6109.    SSComlinOption zOptB( zCom, "B", "B Desc", SSFalse, SSComlinOption::required);
  6110.    SSComlinOption zOptC( zCom, "C", "C Desc", SSFalse, SSComlinOption::optional);
  6111.  
  6112.    try
  6113.       {
  6114.       zCom.parse();
  6115.       }
  6116.    catch ( SSException zExcept)
  6117.       {
  6118.       /* Command line error */
  6119.       }
  6120.  
  6121.    cout << "Option A(" << zOptA.isPlus() << ") Parm(" << zOptA.parm() << ")\n";
  6122.    cout << "Option B(" << zOptB.isPlus() << ") Parm(" << zOptB.parm() << ")\n";
  6123.    cout << "Option C(" << zOptC.isPlus() << ") Parm(" << zOptC.parm() << ")\n";
  6124.    return 0;
  6125.    }
  6126.  
  6127. The header file is sscomlin.hpp. 
  6128.  
  6129.  
  6130. ΓòÉΓòÉΓòÉ 7.2.2. SSComlin ΓòÉΓòÉΓòÉ
  6131.  
  6132.  Constructors 
  6133.  getParms 
  6134.  parse 
  6135.  printFormat 
  6136.  printParms 
  6137.  
  6138.  
  6139. ΓòÉΓòÉΓòÉ 7.2.2.1. Constructors ΓòÉΓòÉΓòÉ
  6140.  
  6141. Signature 
  6142.  
  6143. SSComlin::SSComlin( const char*, int, const char**,
  6144.    const char*, const char* = 0, const char* = 0)
  6145.  
  6146.  Parameters          Meaning 
  6147.  
  6148.  const char*         The command name. 
  6149.  
  6150.  int                 The number of parameters passed on the command line. This 
  6151.                      is the same parameter passed to the main function. 
  6152.  
  6153.  const char**        The array of command line parameters. This is the same 
  6154.                      parameter passed to the main function. 
  6155.  
  6156.  const char*         The description. Shown if the /H option is specified. 
  6157.  
  6158.  const char*         A file name or 0. Zero indicates that the output from the 
  6159.                      /H option, the /P option, and any error messages are 
  6160.                      written to stdout. Otherwise, this parameter is 
  6161.                      interpreted as a file name in which the output is written. 
  6162.  
  6163.  const char*         The path containing the sscomlin.dfa and sscomlin.llr 
  6164.                      tables. The path name must end in a '\' character. 
  6165.                      Internally, Visual Parse++ just appends the table names on 
  6166.                      this string. 
  6167.  
  6168.  Example 
  6169.  
  6170.   int main( int qiArg, char** qapszArg)
  6171.      {
  6172.      SSComlin zComlin( "Command", qiArg, qapszArg, "Description",
  6173.         0, "\\mypath\\");
  6174.  
  6175.  
  6176. ΓòÉΓòÉΓòÉ 7.2.2.2. getParms ΓòÉΓòÉΓòÉ
  6177.  
  6178. The getParms functions gets the list of parameters specified on the command 
  6179. line. These are the parameters not associated with an option. Use this function 
  6180. after the parse function to retrieve the command line parameters. 
  6181.  
  6182. Signature 
  6183.  
  6184. const char** SSComlin::getParms( SSUnsigned32&)
  6185.  
  6186.  Parameters          Meaning 
  6187.  
  6188.  SSUnsigned32&       A reference that is updated with the number of parameters 
  6189.                      in the returned array. 
  6190.  
  6191.  Returns 
  6192.  
  6193.  An array of pointers to the parameters. 
  6194.  
  6195.  Example 
  6196.  
  6197.   SSUnsigned32 zCount;
  6198.   const char** zppParms = qComlin.getParms( zCount);
  6199.  
  6200.  
  6201. ΓòÉΓòÉΓòÉ 7.2.2.3. parse ΓòÉΓòÉΓòÉ
  6202.  
  6203. The parse functions parses the command line. Use this function after you have 
  6204. add your options with the SSComlinOption class. 
  6205.  
  6206. Signature 
  6207.  
  6208. void SSComlin::parse( void)
  6209.  
  6210. Returns 
  6211.  
  6212. Throws an SSException if an error occurs. 
  6213.  
  6214. Example 
  6215.  
  6216. SSComlin zComlin( ...
  6217. ┬╖
  6218. ┬╖
  6219. ┬╖
  6220. try
  6221.    {
  6222.    zComlin.parse();
  6223.    }
  6224. catch ( SSException zExcept)
  6225.    {
  6226.    ┬╖
  6227.    ┬╖
  6228.    ┬╖
  6229.    }
  6230.  
  6231.  
  6232. ΓòÉΓòÉΓòÉ 7.2.2.4. printFormat ΓòÉΓòÉΓòÉ
  6233.  
  6234. The printFormat functions prints the command line format. The /H option prints 
  6235. the same output. 
  6236.  
  6237. Signature 
  6238.  
  6239. void SSComlin::printFormat( SSBooleanValue = SSFalse)
  6240.  
  6241.  Parameters          Meaning 
  6242.  
  6243.  SSBooleanValue      SSTrue means to unconditionally print the help 
  6244.                      information, SSFalse to print the information only if the 
  6245.                      /H option was specified. 
  6246.  
  6247.  Example 
  6248.  
  6249.   int main( int qiArg, const char** qapszArg)
  6250.      {
  6251.      SSComlin zComlin( ...
  6252.      ┬╖
  6253.      ┬╖
  6254.      ┬╖
  6255.      if ( qiArg < xxxxx)
  6256.         {
  6257.         zComlin.printFormat( SSTrue);
  6258.         return 1;
  6259.         }
  6260.  
  6261.  
  6262. ΓòÉΓòÉΓòÉ 7.2.2.5. printParms ΓòÉΓòÉΓòÉ
  6263.  
  6264. The printParms functions prints the command parameters. The /P option prints 
  6265. the same output. 
  6266.  
  6267. Signature 
  6268.  
  6269. void SSComlin::printParms( SSBooleanValue = SSFalse)
  6270.  
  6271.  Parameters          Meaning 
  6272.  
  6273.  SSBooleanValue      SSTrue means to unconditionally print the information, 
  6274.                      SSFalse to print the information only if the /P option was 
  6275.                      specified. 
  6276.  
  6277.  Example 
  6278.  
  6279.   int main( int qiArg, const char** qapszArg)
  6280.      {
  6281.      SSComlin zComlin( ...
  6282.      ┬╖
  6283.      ┬╖
  6284.      ┬╖
  6285.      zComlin.parse();
  6286.   #  if degugging
  6287.      zComlin.printParms( SSTrue);
  6288.   #  endif
  6289.  
  6290.  
  6291. ΓòÉΓòÉΓòÉ 7.2.3. SSComlinOption ΓòÉΓòÉΓòÉ
  6292.  
  6293.  Constructors 
  6294.  isMinus 
  6295.  isPlus 
  6296.  parm 
  6297.  
  6298.  
  6299. ΓòÉΓòÉΓòÉ 7.2.3.1. Constructors ΓòÉΓòÉΓòÉ
  6300.  
  6301. Signature 
  6302.  
  6303. SSComlinOption::SSComlinOption( SSComlin&, const char*,
  6304.    const char*, SSBooleanValue, SSComlinOptionType)
  6305.  
  6306.  Parameters          Meaning 
  6307.  
  6308.  SSComlin&           The SSComlin anchor. 
  6309.  
  6310.  const char*         The option. 
  6311.  
  6312.  const char*         The option description printed with the /H option. 
  6313.  
  6314.  SSBooleanValue      The default value. The value is retrieved with the isPlus 
  6315.                      and isMinus functions. The default value is returned when 
  6316.                      the option is not specified. 
  6317.  
  6318.  SSComlinOptionType  The type, either none, required, or optional. The type 
  6319.                      specifies whether a parameter is not required, required, 
  6320.                      or optional, respectively. 
  6321.  
  6322.  An SSException is thrown if an error occurs, like a duplicate option. 
  6323.  
  6324.  Example 
  6325.  
  6326.   SSComlin zCom;
  6327.   SSComlinOption zOptA( zCom, "A", "A Desc", SSFalse, SSComlinOption::none);
  6328.   SSComlinOption zOptB( zCom, "B", "B Desc", SSFalse, SSComlinOption::optional);
  6329.   SSComlinOption zOptC( zCom, "C", "C Desc", SSFalse, SSComlinOption::required);
  6330.  
  6331.   try
  6332.      {
  6333.      zCom.parse();
  6334.      }
  6335.   catch ( SSException zExcept)
  6336.      {
  6337.      /* Error parsing command */
  6338.      }
  6339.  
  6340.   /* Get parameters */
  6341.  
  6342.  
  6343. ΓòÉΓòÉΓòÉ 7.2.3.2. isMinus ΓòÉΓòÉΓòÉ
  6344.  
  6345. The isMinus functions returns the option value. 
  6346.  
  6347. Signature 
  6348.  
  6349. SSBooleanValue SSComlinOption::isMinus( void)
  6350.  
  6351. Returns 
  6352.  
  6353. SSTrue if the value was '-', SSFalse if the valus was '+'. 
  6354.  
  6355. Example 
  6356.  
  6357. if ( zOptA.isMinus())
  6358.    /* Option A is '-' */
  6359.  
  6360.  
  6361. ΓòÉΓòÉΓòÉ 7.2.3.3. isPlus ΓòÉΓòÉΓòÉ
  6362.  
  6363. The isPlus functions returns the option value. 
  6364.  
  6365. Signature 
  6366.  
  6367. SSBooleanValue SSComlinOption::isPlus( void)
  6368.  
  6369. Returns 
  6370.  
  6371. SSTrue if the value was '+', SSFalse if the valus was '-'. 
  6372.  
  6373. Example 
  6374.  
  6375. if ( zOptA.isPlus())
  6376.    /* Option A is '+' */
  6377.  
  6378.  
  6379. ΓòÉΓòÉΓòÉ 7.2.3.4. parm ΓòÉΓòÉΓòÉ
  6380.  
  6381. The parm functions returns the parameter associated with the option. 
  6382.  
  6383. Signature 
  6384.  
  6385. const char* SSComlinOption::parm( void)
  6386.  
  6387. Returns 
  6388.  
  6389. The parameter or 0. 
  6390.  
  6391. Example 
  6392.  
  6393. const char* zpParm = zOptA.parm();
  6394.  
  6395.  
  6396. ΓòÉΓòÉΓòÉ 7.3. C Bindings ΓòÉΓòÉΓòÉ
  6397.  
  6398.  Concepts 
  6399.  SSComlinCreate 
  6400.  SSComlinDestroy 
  6401.  SSComlinGetParms 
  6402.  SSComlinParse 
  6403.  SSComlinPrintFormat 
  6404.  SSComlinPrintParms 
  6405.  SSComlinOptionCreate 
  6406.  SSComlinOptionGetParm 
  6407.  SSComlinOptionGetValue 
  6408.  
  6409.  
  6410. ΓòÉΓòÉΓòÉ 7.3.1. Concepts ΓòÉΓòÉΓòÉ
  6411.  
  6412. The command line C bindings provide a set of services for specifying the 
  6413. options, parsing, and retrieving parameters on an arbitrary command line. Here 
  6414. is a small example: 
  6415.  
  6416. #include<sscomlin.h>
  6417. int main( int qiArg, char** qapszArg)
  6418.    {
  6419.    void* zpCom;
  6420.    void* zpOptA;
  6421.    void* zpOptB;
  6422.    void* zpOptC;
  6423.    void* zpExcept = 0;
  6424.  
  6425.    zpCom = SSComlinCreate( "Command", qiArg, qapszArg, "Desc",
  6426.       0, 0, &zpExcept);
  6427.  
  6428.    zpOptA = SSComlinOptionCreate( zpCom, "A", "A Desc", SSTrue,
  6429.       SSComlinOptionNone, &zpExcept);
  6430.    zpOptB = SSComlinOptionCreate( zpCom, "B", "B Desc", SSTrue,
  6431.       SSComlinOptionRequired, &zpExcept);
  6432.    zpOptC = SSComlinOptionCreate( zpCom, "C", "C Desc", SSTrue,
  6433.       SSComlinOptionOptional, &zpExcept);
  6434.  
  6435.    zpExcept = SSComlinParse( zpCom);
  6436.    if ( zpExcept)
  6437.       /* Command line error */
  6438.  
  6439.    printf( "OptA(%d) Parm(%s)\n", SSComlinOptionGetValue( zpOptA),
  6440.       SSComlinOptionGetParm( zpOptA));
  6441.    printf( "OptB(%d) Parm(%s)\n", SSComlinOptionGetValue( zpOptB),
  6442.       SSComlinOptionGetParm( zpOptB));
  6443.    printf( "OptC(%d) Parm(%s)\n", SSComlinOptionGetValue( zpOptC),
  6444.       SSComlinOptionGetParm( zpOptC));
  6445.  
  6446.    SSComlinDestroy( zpCom);
  6447.    return 0;
  6448.    }
  6449.  
  6450. The header file is sscomlin.h. 
  6451.  
  6452.  
  6453. ΓòÉΓòÉΓòÉ 7.3.2. SSComlinCreate ΓòÉΓòÉΓòÉ
  6454.  
  6455. SSComlinCreate creates the command line anchor. Command line options created 
  6456. with the SSComlinOptionCreate function are attached to the command line, then 
  6457. the SSComlinParse function is called to process the command line. 
  6458.  
  6459. Signature 
  6460.  
  6461. void* SSComlinCreate( const char*, int, const char**, const char*,
  6462.    const char*, const char*, void**);
  6463.  
  6464.  Parameters          Meaning 
  6465.  
  6466.  const char*         The command name. 
  6467.  
  6468.  int                 The number of parameters. This is the same parameter 
  6469.                      passed on the main function. 
  6470.  
  6471.  const char**        The parameter array. This is the same parameter passed on 
  6472.                      the main function. 
  6473.  
  6474.  const char*         The command description. 
  6475.  
  6476.  const char*         A file name or 0. This parameter indicates where output 
  6477.                      from the /H option, the /P option, or error messages are 
  6478.                      written. Zero specifies stdout, otherwise the data is 
  6479.                      written to the file name specified. 
  6480.  
  6481.  const char*         The path name containing the sscomlin.dfa and sscomlin.llr 
  6482.                      files. The path name must end with a '\' character (if it 
  6483.                      is supplied). Internally, Visual Parse++ concatentates the 
  6484.                      table names on the end of the path name. If 0, the tables 
  6485.                      must be in the current directory. 
  6486.  
  6487.  void**              A pointer that will be updated with an exception 
  6488.                      correlator if an exception occurs. 
  6489.  
  6490.  Returns 
  6491.  
  6492.  A command line correlator or 0. If zero, examine the exception correlator to 
  6493.  determine the cause of the error. 
  6494.  
  6495.  Example 
  6496.  
  6497.   void* zpExcept;
  6498.   void* zpCom = SSComlinCreate( "Command", qiArg, qapszArg, "Desc",
  6499.      0, 0, &zpExcept);
  6500.  
  6501.  
  6502. ΓòÉΓòÉΓòÉ 7.3.3. SSComlinDestroy ΓòÉΓòÉΓòÉ
  6503.  
  6504. SSComlinDestroy destroys a command line correlator. 
  6505.  
  6506. Signature 
  6507.  
  6508. void SSComlinDestroy( void*);
  6509.  
  6510.  Parameters          Meaning 
  6511.  
  6512.  void*               The command line correlator. 
  6513.  
  6514.  Example 
  6515.  
  6516.   SSComlinDestory( zpCom);
  6517.  
  6518.  
  6519. ΓòÉΓòÉΓòÉ 7.3.4. SSComlinGetParms ΓòÉΓòÉΓòÉ
  6520.  
  6521. SSComlinGetParms retrieves the parameters specified after the options. Use this 
  6522. function after SSComlinParse. 
  6523.  
  6524. Signature 
  6525.  
  6526. const char** SSComlinDestroy( void*, SSUnsigned32*);
  6527.  
  6528.  Parameters          Meaning 
  6529.  
  6530.  void*               The command line correlator. 
  6531.  
  6532.  SSUnsigned32*       The address of a variable that is updated with the number 
  6533.                      of parameters in the returned array. 
  6534.  
  6535.  Returns 
  6536.  
  6537.  The parameter array. 
  6538.  
  6539.  Example 
  6540.  
  6541.   SSUnsigned32 zulCount;
  6542.   const char** zppParms = SSComlinGetParms( zpCom, &zulCount);
  6543.  
  6544.  
  6545. ΓòÉΓòÉΓòÉ 7.3.5. SSComlinParse ΓòÉΓòÉΓòÉ
  6546.  
  6547. SSComlinParse parses the command line. 
  6548.  
  6549. Signature 
  6550.  
  6551. void* SSComlinParse( void*);
  6552.  
  6553.  Parameters          Meaning 
  6554.  
  6555.  void*               The command line correlator. 
  6556.  
  6557.  Returns 
  6558.  
  6559.  An exception correlator or 0. Zero indicates success. If non-zero, examine the 
  6560.  exception correlator to determine the cause of the error. 
  6561.  
  6562.  Example 
  6563.  
  6564.   void* zpExcept = SSComlinParse( zpCom);
  6565.  
  6566.  
  6567. ΓòÉΓòÉΓòÉ 7.3.6. SSComlinPrintFormat ΓòÉΓòÉΓòÉ
  6568.  
  6569. SSComlinPrintFormat prints the command line format. The /H option prints the 
  6570. same output. 
  6571.  
  6572. Signature 
  6573.  
  6574. void SSComlinPrintFormat( void*)
  6575.  
  6576.  Parameters          Meaning 
  6577.  
  6578.  void*               A command line correlator. 
  6579.  
  6580.  Example 
  6581.  
  6582.   int main( int qiArg, const char** qapszArg)
  6583.      {
  6584.      void* zpCom = SSComlinCreate( ...
  6585.      ┬╖
  6586.      ┬╖
  6587.      ┬╖
  6588.      if ( qiArg < xxxxx)
  6589.         {
  6590.         SSComlinPrintFormat( zpCom);
  6591.         return 1;
  6592.         }
  6593.  
  6594.  
  6595. ΓòÉΓòÉΓòÉ 7.3.6.1. SSComlinPrintParms ΓòÉΓòÉΓòÉ
  6596.  
  6597. SSComlinPrintParms prints the command parameters. The /P option prints the same 
  6598. output. 
  6599.  
  6600. Signature 
  6601.  
  6602. void SSComlinPrintParms( void*)
  6603.  
  6604.  Parameters          Meaning 
  6605.  
  6606.  void*               A command line correlator. 
  6607.  
  6608.  Example 
  6609.  
  6610.   int main( int qiArg, const char** qapszArg)
  6611.      {
  6612.      void* zpCom = SSComlinCreate( ...
  6613.      ┬╖
  6614.      ┬╖
  6615.      ┬╖
  6616.      SSComlinParse( zpCom);
  6617.   #  if degugging
  6618.      SSComlinPrintParms( zpCom);
  6619.   #  endif
  6620.  
  6621.  
  6622. ΓòÉΓòÉΓòÉ 7.3.7. SSComlinOptionCreate ΓòÉΓòÉΓòÉ
  6623.  
  6624. SSComlinOptionCreate creates a command line option and attaches it to the 
  6625. command line. 
  6626.  
  6627. Signature 
  6628.  
  6629. void* SSComlinOptionCreate( void*, const char*, const char*,
  6630.    SSBooleanValue, SSUnsigned32, void**);
  6631.  
  6632.  Parameters          Meaning 
  6633.  
  6634.  void*               A command line correlator. 
  6635.  
  6636.  const char*         The option. 
  6637.  
  6638.  const char*         The option description. 
  6639.  
  6640.  SSBooleanValue      The defautl value for the option. The value is returned by 
  6641.                      SSComlinOptionGetValue. This value is returned if the 
  6642.                      option is not specified. 
  6643.  
  6644.  SSUnsigned32        The option parameter type, specifying whether the option 
  6645.                      accepts a parameter. Can be either SSComlinOptionNone, 
  6646.                      SSComlinOptionRequired, or SSComlinOptionOptional. 
  6647.  
  6648.  void**              A pointer that will be updated with an exception 
  6649.                      correlator if an exception occurs. 
  6650.  
  6651.  Returns 
  6652.  
  6653.  An option correlator or 0. If zero, examine the exception correlator to 
  6654.  determine the cause of the error. 
  6655.  
  6656.  Example 
  6657.  
  6658.   void* zpCom;
  6659.   void* zpOpt;
  6660.   void* zpExcept;
  6661.  
  6662.   zpCom = SSComlinCreate( "Command", qiArg, qapszArg, "Desc",
  6663.      0, 0, &zpExcept);
  6664.  
  6665.   zpOpt = SSComlinOptionCreate( zpCom, "Opt", "Opt Desc", SSFalse,
  6666.      SSComlinOptionNone, &zpExcept);
  6667.  
  6668.  
  6669. ΓòÉΓòÉΓòÉ 7.3.8. SSComlinOptionGetParm ΓòÉΓòÉΓòÉ
  6670.  
  6671. SSComlinOptionGetParm retrieves the parameter associated with the option. 
  6672.  
  6673. Signature 
  6674.  
  6675. const char* SSComlinOptionGetParm( void*);
  6676.  
  6677.  Parameters          Meaning 
  6678.  
  6679.  void*               The option correlator. 
  6680.  
  6681.  Returns 
  6682.  
  6683.  The parameter string or 0. 
  6684.  
  6685.  Example 
  6686.  
  6687.   const char* zpParms = SSComlinOptionGetParm( zpOpt);
  6688.  
  6689.  
  6690. ΓòÉΓòÉΓòÉ 7.3.9. SSComlinOptionGetValue ΓòÉΓòÉΓòÉ
  6691.  
  6692. SSComlinOptionGetValue retrieves the option value. 
  6693.  
  6694. Signature 
  6695.  
  6696. SSBooleanValue SSComlinOptionGetValue( void*);
  6697.  
  6698.  Parameters          Meaning 
  6699.  
  6700.  void*               The option correlator. 
  6701.  
  6702.  Returns 
  6703.  
  6704.  The value, either SSTrue '+', or SSFalse '-'. 
  6705.  
  6706.  Example 
  6707.  
  6708.   SSBooleanValue zVal = SSComlinOptionGetValue( zpOpt);
  6709.  
  6710.  
  6711. ΓòÉΓòÉΓòÉ 8. Validators ΓòÉΓòÉΓòÉ
  6712.  
  6713.  Concepts 
  6714.  C++ Class 
  6715.  C Functions 
  6716.  
  6717.  
  6718. ΓòÉΓòÉΓòÉ 8.1. Concepts ΓòÉΓòÉΓòÉ
  6719.  
  6720. Validators are useful for things like verifying edit field data, or filtering 
  6721. list box data. You can easily use any lexical analyzer specified in a rule file 
  6722. to validate or filter strings of data. Some class libraries supply limited 
  6723. validator or filtering classes, with the Visual Parse++ validator class (or C 
  6724. function interface), you have the full power of regular expressions to verify a 
  6725. string of data. Any lexical analyzer table, no matter how complicated, can be 
  6726. used with the interfaces provided (currently C and C++). 
  6727.  
  6728.  
  6729. ΓòÉΓòÉΓòÉ 8.2. C++ SSLexValidator Class ΓòÉΓòÉΓòÉ
  6730.  
  6731.  Concepts 
  6732.  Constructors 
  6733.  test 
  6734.  
  6735.  
  6736. ΓòÉΓòÉΓòÉ 8.2.1. Concepts ΓòÉΓòÉΓòÉ
  6737.  
  6738. The SSLexValidator class is used to validate or verify null terminated strings 
  6739. of data using an arbitrary lexical analyzer table. 
  6740.  
  6741. The header file is sslexval.hpp. 
  6742.  
  6743.  
  6744. ΓòÉΓòÉΓòÉ 8.2.2. Constructors ΓòÉΓòÉΓòÉ
  6745.  
  6746. Signature 
  6747.  
  6748. SSLexValidator::SSLexValidator( const char*);
  6749.  
  6750.  Parameters          Meaning 
  6751.  
  6752.  const char*         The lex table name. 
  6753.  
  6754.  Returns 
  6755.  
  6756.  Throws an exception if an error occurs. 
  6757.  
  6758.  Example 
  6759.  
  6760.   SSLexValidator zVal( "table.dfa");
  6761.  
  6762.  
  6763. ΓòÉΓòÉΓòÉ 8.2.3. test ΓòÉΓòÉΓòÉ
  6764.  
  6765. The test function tests the specified data. 
  6766.  
  6767. Signature 
  6768.  
  6769. SSBooleanValue SSLexValidator::test( const char*);
  6770.  
  6771.  Parameters          Meaning 
  6772.  
  6773.  const char*         The data to test. 
  6774.  
  6775.  Returns 
  6776.  
  6777.  SSTrue indicates the data was accepted by the validator. 
  6778.  
  6779.  Example 
  6780.  
  6781.   SSLexValidator zVal( "table.dfa");
  6782.   SSBooleanValue zTest = zVal.test( "Test string");
  6783.  
  6784.  
  6785. ΓòÉΓòÉΓòÉ 8.3. C SSLexValidator Functions ΓòÉΓòÉΓòÉ
  6786.  
  6787.  Concepts 
  6788.  SSLexValidatorCreate 
  6789.  SSLexValidatorDestroy 
  6790.  SSLexValidatorTest 
  6791.  
  6792.  
  6793. ΓòÉΓòÉΓòÉ 8.3.1. Concepts ΓòÉΓòÉΓòÉ
  6794.  
  6795. The SSLexValidator C functions are used to validate or verify null terminated 
  6796. strings of data using an arbitrary lexical analyzer table. 
  6797.  
  6798. The header file is sslexval.h. 
  6799.  
  6800.  
  6801. ΓòÉΓòÉΓòÉ 8.3.2. SSLexValidatorCreate ΓòÉΓòÉΓòÉ
  6802.  
  6803. The SSLexValidatorCreate function creates a validator. 
  6804.  
  6805. Signature 
  6806.  
  6807. void* SSLexValidatorCreate( const char*, void**);
  6808.  
  6809.  Parameters          Meaning 
  6810.  
  6811.  const char*         The lex table name. 
  6812.  
  6813.  void**              An area that is updated with an exception correlator if an 
  6814.                      error occurs. 
  6815.  
  6816.  Returns 
  6817.  
  6818.  The validator correlator or 0. Zero indicates an error occurred, examine the 
  6819.  returned exception correlator. 
  6820.  
  6821.  Example 
  6822.  
  6823.   void* zpExcept;
  6824.   void* zpVal = SSLexValidatorCreate( "table.dfa", &zpExcept);
  6825.  
  6826.  
  6827. ΓòÉΓòÉΓòÉ 8.3.3. SSLexValidatorDestroy ΓòÉΓòÉΓòÉ
  6828.  
  6829. The SSLexValidatorDestroy function destroys a validator. 
  6830.  
  6831. Signature 
  6832.  
  6833. void SSLexValidatorDestroy( void*);
  6834.  
  6835.  Parameters          Meaning 
  6836.  
  6837.  void*               A validator correlator. 
  6838.  
  6839.  Example 
  6840.  
  6841.   SSLexValidatorDestroy( zpVal);
  6842.  
  6843.  
  6844. ΓòÉΓòÉΓòÉ 8.3.4. SSLexValidatorTest ΓòÉΓòÉΓòÉ
  6845.  
  6846. The SSLexValidatorTest function verifies the specified string. 
  6847.  
  6848. Signature 
  6849.  
  6850. SSBooleanValue SSLexValidatorTest( void*, const char*);
  6851.  
  6852.  Parameters          Meaning 
  6853.  
  6854.  void*               A validator correlator. 
  6855.  
  6856.  const char*         A null terminated test string. 
  6857.  
  6858.  Returns 
  6859.  
  6860.  SSTrue indicates a match. 
  6861.  
  6862.  Example 
  6863.  
  6864.   SSBooleanValue zTest = SSLexValidatorTest( zpVal, "Test data");
  6865.  
  6866.  
  6867. ΓòÉΓòÉΓòÉ 9. Commands ΓòÉΓòÉΓòÉ
  6868.  
  6869.  Concepts 
  6870.  Options 
  6871.  C File 
  6872.  C++ File 
  6873.  REXX File 
  6874.  Symbol File 
  6875.  Lex Table File 
  6876.  Lex Machine File 
  6877.  Yacc Table File 
  6878.  Yacc Machine File 
  6879.  Error Messages 
  6880.  
  6881.  
  6882. ΓòÉΓòÉΓòÉ 9.1. Concepts ΓòÉΓòÉΓòÉ
  6883.  
  6884. To compile and test your rule file, use the SSPARSE and SSVPARSE commands. 
  6885.  
  6886. SSPARSE is the command line compiler used to compile rule files and generate 
  6887. language bindings and other information files. 
  6888.  
  6889. SSVPARSE invokes the graphical rule file debugger.  It has all the capabilities 
  6890. of the SSPARSE command plus the ability to completely debug your rule file. 
  6891. See the Visual Parse++ User's Guide for more information. 
  6892.  
  6893. There are several files which can be generated by using the SSPARSE command or 
  6894. the Visual Parse++ debugger.  These files supply the language bindings 
  6895. necessary for application development plus additional files to aid the 
  6896. development process. 
  6897.  
  6898. The parameters for both commands are identical with 1 exception. (The SSVPARSE 
  6899. command has a /T parameter.)  Note: The SSVPARSE command opens an output file 
  6900. in the current directory called ssvparse.out.  This file will contain any error 
  6901. messages generated by the SSVPARSE command if an error occurs. 
  6902.  
  6903.  
  6904. ΓòÉΓòÉΓòÉ 9.2. Options ΓòÉΓòÉΓòÉ
  6905.  
  6906. The command line syntax is as follows: 
  6907.  
  6908. command [ options ] rulefile
  6909.  
  6910.  Parameter      Meaning 
  6911.  
  6912.  command        Either SSPARSE or SSVPARSE. 
  6913.  
  6914.  options        The options. 
  6915.  
  6916.  rulefile       A rule file. 
  6917.  
  6918.  Each option has syntax: 
  6919.  
  6920.   (-|/)option[ (+|-) ][ ]parameter
  6921.  
  6922.  In words, options are preceded by either a '-' or a '/' and followed by an 
  6923.  optional '+' or '-'.  If the '+' or '-' is missing, '+' is assumed. If the 
  6924.  parameter is optional, it must be concatenated on the end of the option string 
  6925.  (without the '+' sign). If it is required, there can be intervening white 
  6926.  space. 
  6927.  
  6928.  Option         Meaning 
  6929.  
  6930.  /C             Generate the C header file.  The default is '-'. The optional 
  6931.                 parameter is a file name which defaults to the rule file name 
  6932.                 with a '.yh' extension. See C File for more information. 
  6933.  
  6934.  /Cpp           Generate the C++ header file.  The default is '-'. The optional 
  6935.                 parameter is a file name which defaults to the rule file name 
  6936.                 with a '.yhh' extension. See C++ File for more information. 
  6937.  
  6938.  /Fs            Generate a symbol file.  The default is '-' if there are no 
  6939.                 errors in the rule file, else '+'. The optional parameter is 
  6940.                 the file name which defaults to the rule file name with a 
  6941.                 '.sym' extension.  See Symbol File for more information. 
  6942.  
  6943.  /H             Print a list of the options. For the SSVPARSE command, the 
  6944.                 printout goes to the file ssvparse.out in the current 
  6945.                 directory. 
  6946.  
  6947.  /Lc            For C++, the SSLex derived class name. For C, the prefix used 
  6948.                 on function related to the lexical analyzer. For REXX, the 
  6949.                 prefix used on function and variable names related to the 
  6950.                 lexical analyzer.  The default is '+'.  The optional parameter 
  6951.                 defaults to 'ALexClass'. 
  6952.  
  6953.  /Le            The prefix used on the %expression list identifier constants. 
  6954.                 The default is '+'.  The optional parameter is the prefix which 
  6955.                 defaults to 'ALexExpressionList'. 
  6956.  
  6957.  /Lm            Print the lex machine. The default is '-'.  The optional 
  6958.                 parameter is the file name which defaults to the rule file name 
  6959.                 with a '.dfx' extension. See Lex Machine File for more 
  6960.                 information. 
  6961.  
  6962.  /Lp            The prefix used on the %expression list token constants. The 
  6963.                 default is '+'.  The optional parameter is the prefix which 
  6964.                 defaults to 'ALex'. 
  6965.  
  6966.  /Lt            Generate a lexical analyzer table.  The default is '+'. The 
  6967.                 optional parameter is the file name which defaults to the rule 
  6968.                 file name with a '.dfa' extension. See Lex Table File for more 
  6969.                 information. 
  6970.  
  6971.  /P             Print a list of the parameters that were specified.  This is 
  6972.                 useful for debugging a command line that is not behaving as 
  6973.                 expected.  For the SSVPARSE command, the printout goes to the 
  6974.                 file ssvparse.out in the current directory. 
  6975.  
  6976.  /Rx            Generate the REXX file.  The default is '-'. The optional 
  6977.                 parameter is a file name which defaults to the rule file name 
  6978.                 with a '.cmd' extension. See REXX File for more information. 
  6979.  
  6980.  /Yc            For C++, the SSYacc derived class name. For C, the prefix used 
  6981.                 on functions related to the parser. For REXX, a prefix used on 
  6982.                 function and variable names related to the parser. The default 
  6983.                 is '+'.  The optional parameter defaults to 'AYaccClass'. 
  6984.  
  6985.  /Ym            Print the parsing machine. The default is '-'.  The optional 
  6986.                 parameter is the file name which defaults to the rule file name 
  6987.                 with a '.llx' extension. See Yacc Machine File for more 
  6988.                 information. 
  6989.  
  6990.  /Yp            The prefix used on the %production labels. The default is '+'. 
  6991.                 The optional parameter is the prefix which defaults to 'AYacc'. 
  6992.  
  6993.  /Yt            Generate a parser table.  The default is '+'. The optional 
  6994.                 parameter is the file name which defaults to the rule file name 
  6995.                 with a '.llr' extension. See Yacc Table File for more 
  6996.                 information. 
  6997.  
  6998.  /T             The tab amount.  Valid only on the SSVPARSE command. The 
  6999.                 parameter is a numeric argument. See the Visual Parse++ User's 
  7000.                 Guide for more information on the tab amount. 
  7001.  
  7002.  
  7003. ΓòÉΓòÉΓòÉ 9.3. C File ΓòÉΓòÉΓòÉ
  7004.  
  7005. The C header file (with default extension '.yh') contains the language bindings 
  7006. for C.  You can tailor this file with either command line options or the Visual 
  7007. Parse++ debugger. 
  7008.  
  7009. A small example will be used to illustrate the concepts. Compile the ssexpr.ycc 
  7010. sample with these parameters: 
  7011.  
  7012. SSPARSE /C /LcALex /LpALexToken /YcAYacc /YpAYaccProd ssexpr.ycc
  7013.  
  7014. The file ssexpr.yh will look like the following: 
  7015.  
  7016. #if !defined( SSEXPRSSH)
  7017. #  define SSEXPRSSH
  7018. #  include<sslexc.h>
  7019. #  include<ssyaccc.h>
  7020.  
  7021. #  define ALexExpressionListMain       0
  7022.  
  7023. #  define ALexTokenEnd                 2
  7024. #  define ALexTokenPlus                3
  7025. #  define ALexTokenMinus               4
  7026. #  define ALexTokenDiv                 5
  7027. #  define ALexTokenMult                6
  7028. #  define ALexTokenPower               7
  7029. #  define ALexTokenOParen              8
  7030. #  define ALexTokenCParen              9
  7031. #  define ALexTokenNumber              10
  7032. #  define ALexTokenName                11
  7033.  
  7034. #  define AYaccProdStart               1
  7035. #  define AYaccProdStartList           2
  7036. #  define AYaccProdExprSingle          3
  7037. #  define AYaccProdExprPlus            4
  7038. #  define AYaccProdExprMinus           5
  7039. #  define AYaccProdExprMult            6
  7040. #  define AYaccProdExprDiv             7
  7041. #  define AYaccProdExprPower           8
  7042. #  define AYaccProdExprNested          9
  7043. #  define AYaccProdExprName            10
  7044. #  define AYaccProdExprNumber          11
  7045.  
  7046.    SSRetConstChar ALexTokenToConstChar( SSUnsigned32 qulToken)
  7047.       {
  7048.       const char* zpchToken;
  7049.       switch ( qulToken)
  7050.          {
  7051.          case ALexTokenEnd:
  7052.             zpchToken = ";";
  7053.             break;
  7054.  
  7055.          case ALexTokenPlus:
  7056.             zpchToken = "+";
  7057.             break;
  7058.  
  7059.          case ALexTokenMinus:
  7060.             zpchToken = "-";
  7061.             break;
  7062.  
  7063.          case ALexTokenDiv:
  7064.             zpchToken = "/";
  7065.             break;
  7066.  
  7067.          case ALexTokenMult:
  7068.             zpchToken = "*";
  7069.             break;
  7070.  
  7071.          case ALexTokenPower:
  7072.             zpchToken = "**";
  7073.             break;
  7074.  
  7075.          case ALexTokenOParen:
  7076.             zpchToken = "(";
  7077.             break;
  7078.  
  7079.          case ALexTokenCParen:
  7080.             zpchToken = ")";
  7081.             break;
  7082.  
  7083.          case ALexTokenNumber:
  7084.             zpchToken = "n";
  7085.             break;
  7086.  
  7087.          case ALexTokenName:
  7088.             zpchToken = "name";
  7089.             break;
  7090.  
  7091.          case SSYaccErrorToken:
  7092.             zpchToken = "%error";
  7093.             break;
  7094.  
  7095.          case SSYaccEofToken:
  7096.             zpchToken = "eof";
  7097.             break;
  7098.  
  7099.          default:
  7100.             zpchToken = SSLexTokenNotFound;
  7101.          }
  7102.       return zpchToken;
  7103.       }
  7104.  
  7105.    SSRetVoidP AYaccReduce( SSUnsigned32 qulProd, SSUnsigned32 qulSize, void* qpParm)
  7106.       {
  7107.       switch ( qulProd)
  7108.          {
  7109.          case AYaccProdStart:
  7110.          /* start -> expressionStatement */
  7111.             break;
  7112.  
  7113.          case AYaccProdStartList:
  7114.          /* start -> start expressionStatement */
  7115.             break;
  7116.  
  7117.          case AYaccProdExprSingle:
  7118.          /* expressionStatement -> expression ; */
  7119.             break;
  7120.  
  7121.          case AYaccProdExprPlus:
  7122.          /* expression -> expression + expression */
  7123.             break;
  7124.  
  7125.          case AYaccProdExprMinus:
  7126.          /* expression -> expression - expression */
  7127.             break;
  7128.  
  7129.          case AYaccProdExprMult:
  7130.          /* expression -> expression * expression */
  7131.             break;
  7132.  
  7133.          case AYaccProdExprDiv:
  7134.          /* expression -> expression / expression */
  7135.             break;
  7136.  
  7137.          case AYaccProdExprPower:
  7138.          /* expression -> expression ** expression */
  7139.             break;
  7140.  
  7141.          case AYaccProdExprNested:
  7142.          /* expression -> ( expression ) */
  7143.             break;
  7144.  
  7145.          case AYaccProdExprName:
  7146.          /* expression -> name */
  7147.             break;
  7148.  
  7149.          case AYaccProdExprNumber:
  7150.          /* expression -> n */
  7151.             break;
  7152.  
  7153.          }
  7154.  
  7155.       return SSYaccStackElementCreate( 0, 0);
  7156.       }
  7157.  
  7158. #endif
  7159.  
  7160.  
  7161. ΓòÉΓòÉΓòÉ 9.4. C++ File ΓòÉΓòÉΓòÉ
  7162.  
  7163. The C++ header file (with default extension '.yhh') contains the language 
  7164. bindings for C++.  You can tailor this file with either command line options or 
  7165. the Visual Parse++ debugger. 
  7166.  
  7167. Complile the ssexpr.ycc sample with the following parameters: 
  7168.  
  7169. SSPARSE /Cpp /LcALex /LpALexToken /YcAYacc /YpAYaccProd ssexpr.ycc
  7170.  
  7171. The file ssexpr.yh will look like the following. 
  7172.  
  7173. #if !defined( SSEXPRSSHH)
  7174. #  define SSEXPRSSHH
  7175. #  include<sslex.hpp>
  7176. #  include<ssyacc.hpp>
  7177.  
  7178. #  define ALexExpressionListMain       0
  7179.  
  7180. #  define ALexTokenEnd                 2
  7181. #  define ALexTokenPlus                3
  7182. #  define ALexTokenMinus               4
  7183. #  define ALexTokenDiv                 5
  7184. #  define ALexTokenMult                6
  7185. #  define ALexTokenPower               7
  7186. #  define ALexTokenOParen              8
  7187. #  define ALexTokenCParen              9
  7188. #  define ALexTokenNumber              10
  7189. #  define ALexTokenName                11
  7190.  
  7191. #  define AYaccProdStart               1
  7192. #  define AYaccProdStartList           2
  7193. #  define AYaccProdExprSingle          3
  7194. #  define AYaccProdExprPlus            4
  7195. #  define AYaccProdExprMinus           5
  7196. #  define AYaccProdExprMult            6
  7197. #  define AYaccProdExprDiv             7
  7198. #  define AYaccProdExprPower           8
  7199. #  define AYaccProdExprNested          9
  7200. #  define AYaccProdExprName            10
  7201. #  define AYaccProdExprNumber          11
  7202.  
  7203.    class ALex : public SSLex
  7204.       {
  7205.       public:
  7206.          SSConstr            ALex( const char*);
  7207.          const char*         tokenToConstChar( SSUnsigned32);
  7208.       };
  7209.  
  7210.    ALex::ALex( const char* qpszFile) :
  7211.       SSLex( qpszFile, "ssexpr.dfa")
  7212.       {
  7213.       }
  7214.  
  7215.    const char* ALex::tokenToConstChar( SSUnsigned32 qulToken)
  7216.       {
  7217.       const char* zpchToken;
  7218.       switch ( qulToken)
  7219.          {
  7220.          case ALexTokenEnd:
  7221.             zpchToken = ";";
  7222.             break;
  7223.  
  7224.          case ALexTokenPlus:
  7225.             zpchToken = "+";
  7226.             break;
  7227.  
  7228.          case ALexTokenMinus:
  7229.             zpchToken = "-";
  7230.             break;
  7231.  
  7232.          case ALexTokenDiv:
  7233.             zpchToken = "/";
  7234.             break;
  7235.  
  7236.          case ALexTokenMult:
  7237.             zpchToken = "*";
  7238.             break;
  7239.  
  7240.          case ALexTokenPower:
  7241.             zpchToken = "**";
  7242.             break;
  7243.  
  7244.          case ALexTokenOParen:
  7245.             zpchToken = "(";
  7246.             break;
  7247.  
  7248.          case ALexTokenCParen:
  7249.             zpchToken = ")";
  7250.             break;
  7251.  
  7252.          case ALexTokenNumber:
  7253.             zpchToken = "n";
  7254.             break;
  7255.  
  7256.          case ALexTokenName:
  7257.             zpchToken = "name";
  7258.             break;
  7259.  
  7260.          case SSYaccErrorToken:
  7261.             zpchToken = "%error";
  7262.             break;
  7263.  
  7264.          case SSYaccEofToken:
  7265.             zpchToken = "eof";
  7266.             break;
  7267.  
  7268.          default:
  7269.             zpchToken = SSLexTokenNotFound;
  7270.          }
  7271.       return zpchToken;
  7272.       }
  7273.  
  7274.    class AYacc : public SSYacc
  7275.       {
  7276.       public:
  7277.          SSConstr            AYacc( const char*);
  7278.          SSYaccStackElement* reduce( SSUnsigned32, SSUnsigned32);
  7279.  
  7280.       protected:
  7281.          SSLex               oLex;
  7282.       };
  7283.  
  7284.    AYacc::AYacc( const char* qpszFile) :
  7285.       SSYacc("ssexpr.llr"),
  7286.       oLex( qpszFile, "ssexpr.dfa")
  7287.       {
  7288.       setLex( oLex);
  7289.       }
  7290.  
  7291.    SSYaccStackElement* AYacc::reduce( SSUnsigned32 qulProd,
  7292.       SSUnsigned32 qulSize)
  7293.       {
  7294.       switch ( qulProd)
  7295.          {
  7296.          case AYaccProdStart:
  7297.          // start -> expressionStatement
  7298.             break;
  7299.  
  7300.          case AYaccProdStartList:
  7301.          // start -> start expressionStatement
  7302.             break;
  7303.  
  7304.          case AYaccProdExprSingle:
  7305.          // expressionStatement -> expression ;
  7306.             break;
  7307.  
  7308.          case AYaccProdExprPlus:
  7309.          // expression -> expression + expression
  7310.             break;
  7311.  
  7312.          case AYaccProdExprMinus:
  7313.          // expression -> expression - expression
  7314.             break;
  7315.  
  7316.          case AYaccProdExprMult:
  7317.          // expression -> expression * expression
  7318.             break;
  7319.  
  7320.          case AYaccProdExprDiv:
  7321.          // expression -> expression / expression
  7322.             break;
  7323.  
  7324.          case AYaccProdExprPower:
  7325.          // expression -> expression ** expression
  7326.             break;
  7327.  
  7328.          case AYaccProdExprNested:
  7329.          // expression -> ( expression )
  7330.             break;
  7331.  
  7332.          case AYaccProdExprName:
  7333.          // expression -> name
  7334.             break;
  7335.  
  7336.          case AYaccProdExprNumber:
  7337.          // expression -> n
  7338.             break;
  7339.  
  7340.          }
  7341.  
  7342.       return stackElement();
  7343.       }
  7344.  
  7345. #endif
  7346.  
  7347.  
  7348. ΓòÉΓòÉΓòÉ 9.5. REXX File ΓòÉΓòÉΓòÉ
  7349.  
  7350. The REXX file (with default extension '.cmd') contains the language bindings 
  7351. for REXX.  You can tailor this file with either command line options or the 
  7352. Visual Parse++ debugger. 
  7353.  
  7354. Complile the ssexpr.ycc sample with the following parameters: 
  7355.  
  7356. SSPARSE /Rx /LcALex /LpALexToken /YcAYacc /YpAYaccProd ssexpr.ycc
  7357.  
  7358. The file ssexpr.cmd will look like the following. 
  7359.  
  7360. /* Visual Parse++ REXX function*/
  7361.  
  7362. SSDll = 'c:\ss\bin\SSVYREXX.DLL'
  7363. call RxFuncAdd 'SSLoadRexxFunctions', SSDll, 'SSLoadRexxFunctions'
  7364. call SSLoadRexxFunctions SSDll
  7365.  
  7366. signal on error name SSTerminate
  7367. signal on syntax name SSTerminate
  7368. signal on failure name SSTerminate
  7369.  
  7370. ALexTokenEnd        = 2
  7371. ALexTokenPlus       = 3
  7372. ALexTokenMinus      = 4
  7373. ALexTokenDiv        = 5
  7374. ALexTokenMult       = 6
  7375. ALexTokenPower      = 7
  7376. ALexTokenOParen     = 8
  7377. ALexTokenCParen     = 9
  7378. ALexTokenNumber     = 10
  7379. ALexTokenName       = 11
  7380.  
  7381. AYaccProdStart      = 1
  7382. AYaccProdStartList  = 2
  7383. AYaccProdExprSingle = 3
  7384. AYaccProdExprPlus   = 4
  7385. AYaccProdExprMinus  = 5
  7386. AYaccProdExprMult   = 6
  7387. AYaccProdExprDiv    = 7
  7388. AYaccProdExprPower  = 8
  7389. AYaccProdExprNested = 9
  7390. AYaccProdExprName   = 10
  7391. AYaccProdExprNumber = 11
  7392.  
  7393. ALexTable = 'ssexpr.dfa'
  7394. ALexConsumer = 'Visual Parse++ Consumer'
  7395. ALex = SSLexCreate( ALexTable, ALexConsumer, SSFile)
  7396. AYaccTable = 'ssexpr.llr'
  7397. AYacc = SSYaccCreate( ALex, AYaccTable)
  7398.  
  7399. do forever
  7400.    SSRet = SSYaccParse( AYacc, SSParm)
  7401.    select
  7402.       when SSRet = SSOK then
  7403.          say 'Lexeme 'SSParm.0' at' SSParm.2','SSParm.3' Token = 'SSParm.1
  7404.       when SSRet = SSMORE then do
  7405.          SSRet = ALexProcessMore()
  7406.          if SSRet <>  then
  7407.             SSRet = SSLexAddData( ALex, SSRet)
  7408.          end
  7409.       when SSRet = SSSHIFT then
  7410.          say 'Shift 'SSParm.0' at' SSParm.2','SSParm.3' Token = 'SSParm.1
  7411.       when SSRet = SSREDUCE then
  7412.          call AYaccReduce
  7413.       when SSRet = SSACCEPT then do
  7414.          say 'Accept'
  7415.          leave
  7416.          end
  7417.       when SSRet = SSLEXERROR then do
  7418.          SSRet = ALexProcessError()
  7419.          if SSRet < 0 then leave
  7420.          end
  7421.       when SSRet = SSYACCERROR then do
  7422.          SSRet = AYaccProcessError()
  7423.          if SSRet < 0 then leave
  7424.          end
  7425.       otherwise
  7426.          say 'Unprocessed parse 'SSRet
  7427.    end
  7428. end
  7429.  
  7430. call SSUnloadRexxFunctions
  7431. return 0
  7432.  
  7433.  
  7434.  
  7435. AYaccProcessError:
  7436.    say 'Parse error on line 'SSParm.2' at offset 'SSParm.3': 'SSParm.0','SSResult
  7437.    return -1
  7438.  
  7439. ALexProcessMore:
  7440.    return ''
  7441.  
  7442. ALexProcessError:
  7443.    say 'Invalid lexeme on line 'SSParm.2' at offset 'SSParm.3': 'SSParm.0
  7444.    return -1
  7445.  
  7446. AYaccReduce:
  7447.    say 'Reduce 'SSParm.0
  7448.    select
  7449.       when SSParm.0 = AYaccProdStart then do
  7450.       /* start -> expressionStatement */
  7451.          end
  7452.  
  7453.       when SSParm.0 = AYaccProdStartList then do
  7454.       /* start -> start expressionStatement */
  7455.          end
  7456.  
  7457.       when SSParm.0 = AYaccProdExprSingle then do
  7458.       /* expressionStatement -> expression ; */
  7459.          end
  7460.  
  7461.       when SSParm.0 = AYaccProdExprPlus then do
  7462.       /* expression -> expression + expression */
  7463.          end
  7464.  
  7465.       when SSParm.0 = AYaccProdExprMinus then do
  7466.       /* expression -> expression - expression */
  7467.          end
  7468.  
  7469.       when SSParm.0 = AYaccProdExprMult then do
  7470.       /* expression -> expression * expression */
  7471.          end
  7472.  
  7473.       when SSParm.0 = AYaccProdExprDiv then do
  7474.       /* expression -> expression / expression */
  7475.          end
  7476.  
  7477.       when SSParm.0 = AYaccProdExprPower then do
  7478.       /* expression -> expression ** expression */
  7479.          end
  7480.  
  7481.       when SSParm.0 = AYaccProdExprNested then do
  7482.       /* expression -> ( expression ) */
  7483.          end
  7484.  
  7485.       when SSParm.0 = AYaccProdExprName then do
  7486.       /* expression -> name */
  7487.          end
  7488.  
  7489.       when SSParm.0 = AYaccProdExprNumber then do
  7490.       /* expression -> n */
  7491.          end
  7492.  
  7493.    end
  7494.    return
  7495.  
  7496. SSTerminate:
  7497.    say 'Error on line 'sigl': 'SSResult
  7498.    call SSUnloadRexxFunctions
  7499.    exit 1
  7500.  
  7501.  
  7502. ΓòÉΓòÉΓòÉ 9.6. Symbol File ΓòÉΓòÉΓòÉ
  7503.  
  7504. The symbol file (with default extension '.sym')  contains information about the 
  7505. terminal and nonterminal symbols in your rule file. 
  7506.  
  7507. If errors are detected, you may need to view this file to determine the cause 
  7508. of the error. 
  7509.  
  7510. An entry in the file has the following format: 
  7511.  
  7512. Symbol Alias Type Assoc Prec
  7513.  
  7514.  Column         Meaning 
  7515.  
  7516.  Symbol         The symbol name. 
  7517.  
  7518.  Alias          The alias, if one was specified. 
  7519.  
  7520.  Type           Either terminal or nonterminal. 
  7521.  
  7522.  Assoc          The associativity, either left, right, of nonassoc. 
  7523.  
  7524.  Prec           The precedence. 
  7525.  
  7526.  
  7527. ΓòÉΓòÉΓòÉ 9.7. Lex Table File ΓòÉΓòÉΓòÉ
  7528.  
  7529. The lex table file (with default extension '.dfa') contains the lexical 
  7530. analyzer.  You can access this file with the SSLex and SSLexTable classes. 
  7531.  
  7532.  
  7533. ΓòÉΓòÉΓòÉ 9.8. Lex Machine File ΓòÉΓòÉΓòÉ
  7534.  
  7535. The lex machine file (with default extension '.dfx') contains a printout of the 
  7536. lexical analyzer.  Examining this file can be helpful for diagnosing lexical 
  7537. analyzers that aren't behaving as expected. The file has the following format: 
  7538.  
  7539. *
  7540. * Lex machine for name
  7541. *
  7542.  
  7543. State(nnn)
  7544.  
  7545.    start  end   Next(nnn)
  7546.    ┬╖      ┬╖     ┬╖
  7547.    ┬╖      ┬╖     ┬╖
  7548.    ┬╖      ┬╖     ┬╖
  7549.    start  end   Next(nnn)
  7550.    ┬╖      ┬╖     ┬╖
  7551.    ┬╖      ┬╖     ┬╖
  7552.    ┬╖      ┬╖     ┬╖
  7553.  
  7554. The name is the %expression list name. Each entry is a range of code points 
  7555. that transition to the state indicated. 
  7556.  
  7557.  
  7558. ΓòÉΓòÉΓòÉ 9.9. Yacc Table File ΓòÉΓòÉΓòÉ
  7559.  
  7560. The yacc table file (with default extension '.llr') contains the parser.  You 
  7561. can access this file with the SSYacc and SSYaccTable classes. 
  7562.  
  7563.  
  7564. ΓòÉΓòÉΓòÉ 9.10. Yacc Machine File ΓòÉΓòÉΓòÉ
  7565.  
  7566. The yacc machine file (with default extension '.llx') contains a printout of 
  7567. the parser.  Examining this file can be helpful for diagnosing parsers that 
  7568. aren't behaving as expected. The file has the following format: 
  7569.  
  7570. State(nnn)
  7571.    Kernel Items
  7572. -------------------------------------------------------------
  7573.    Other Items
  7574.  
  7575. State(nnn)
  7576.    Kernel Items
  7577. -------------------------------------------------------------
  7578.    Other Items
  7579.  
  7580.    ┬╖
  7581.    ┬╖
  7582.    ┬╖
  7583.  
  7584. Items look like: 
  7585.  
  7586. leftside -> rightside [ lookaheads ]
  7587.  
  7588. where the item is listed followed by the valid lookaheads for this item. 
  7589. Lookaheads are only listed for items that will cause a reduce. 
  7590.  
  7591.  
  7592. ΓòÉΓòÉΓòÉ 10. Error Messages ΓòÉΓòÉΓòÉ
  7593.  
  7594. The following is a list of error messages that you may receive. 
  7595.  
  7596.  Error               Meaning 
  7597.  
  7598.  SSCmd0001e          A command line parameter was too long for the buffer. 
  7599.  
  7600.  SSCmd0002e          A command line argument was too long. 
  7601.  
  7602.  SSCmd0003e          An invalid option was specified. 
  7603.  
  7604.  SSCmd0004e          A parameter on an option was required but not specified. 
  7605.  
  7606.  SSCmd0005e          A parameter on an option was not allowed, but one was 
  7607.                      supplied. 
  7608.  
  7609.  SSCmd0006e          A duplicate option was specified. 
  7610.  
  7611.  SSComlin0001e       An invalid option was specified. 
  7612.  
  7613.  SSComlin0002e       A parameter was expected but not supplied. 
  7614.  
  7615.  SSComlin0003e       A parameter was not expected, but one was supplied. 
  7616.  
  7617.  SSComlin0004e       A duplicate option was specified. 
  7618.  
  7619.  SSComlin0005e       A syntax error was detected. 
  7620.  
  7621.  SSFLex0001e         An invalid token was detected in a regular expression. 
  7622.  
  7623.  SSFLex0002e         Either the macro was not found or there is a series of 
  7624.                      macro definitions that are circular. 
  7625.  
  7626.  SSFLex0003e         A syntax error was detected in a regular expression. 
  7627.  
  7628.  SSFLex0004e         A macro was encountered in a regular expression, but there 
  7629.                      are no macro definitions. 
  7630.  
  7631.  SSFLex0005e         An empty character class ([]) was detected in a regular 
  7632.                      expression. 
  7633.  
  7634.  SSFLex0006e         The \d, \o, or \x numeric constant cannot fit in a 32 bit 
  7635.                      unsigned integer. 
  7636.  
  7637.  SSFLex0007e         An invalid range was detected on the {n,n} operator in a 
  7638.                      regular expression.  The first number must be greater than 
  7639.                      or equal to 0, and less than the second number. 
  7640.  
  7641.  SSFLex0008e         The table is too big for the platform. 
  7642.  
  7643.  SSFile0001e         The file could not be opened. 'errno' is displayed in the 
  7644.                      message. 
  7645.  
  7646.  SSFile0002e         An invalid file name was specified. 
  7647.  
  7648.  SSFile0005e         A read failed for a file. 
  7649.  
  7650.  SSLex0001e          The file could not be opened. 'errno' is displayad in the 
  7651.                      message. 
  7652.  
  7653.  SSLex0002e          The file length could not be retrieved. 
  7654.  
  7655.  SSLex0003e          An invalid consumer type was specified. 
  7656.  
  7657.  SSLex0004e          The lexeme could not fit in the consumer buffer, and the 
  7658.                      buffer could not be expanded. 
  7659.  
  7660.  SSLex0006e          An invalid lexeme was detected. 
  7661.  
  7662.  SSLex0101e          The file could not be opened. 
  7663.  
  7664.  SSLex0102e          The file length could not be retrieved, or a read error 
  7665.                      occurred. 
  7666.  
  7667.  SSLex0103e          A lexeme could not fit in the consumer buffer, and the 
  7668.                      buffer could not be expanded. 
  7669.  
  7670.  SSLex0104e          An invalid table was detected. 
  7671.  
  7672.  SSLex0105e          An invalid token was detected. 
  7673.  
  7674.  SSLex0106e          An invalid expression list index was specified. 
  7675.  
  7676.  SSLex0107e          A lexer requires a table and a consumer to function, one 
  7677.                      of them is missing. 
  7678.  
  7679.  SSLifo0001e         A stack full condition was detected. 
  7680.  
  7681.  SSLifo0002e         A stack is empty and a query was performed. 
  7682.  
  7683.  SSLifo0003e         An invalid index was specified on a stack probe. 
  7684.  
  7685.  SSLifo0004e         An attempt was made to pop an empty stack. 
  7686.  
  7687.  SSLlr0015e          A parse table is too big. 
  7688.  
  7689.  SSVP0001e           You selected Debug/Animate from the menubar, but the timer 
  7690.                      could not be started. There are too many system timers, 
  7691.                      try again later. 
  7692.  
  7693.  SSVP0002e           Visual Parse++ was unable to register a required class. 
  7694.  
  7695.  SSVP0003e           Visual Parse++ was unable to create a window. 
  7696.  
  7697.  SSVP0004e           An expression list could not be located. 
  7698.  
  7699.  SSVP0006e           The tab amount must be between 0 and 32. 
  7700.  
  7701.  SSVP0007e           A failure occurred while lexing. You probably popped the 
  7702.                      last lexer on the expression list stack. 
  7703.  
  7704.  SSYacc0001e         The parse table could not be opened. 
  7705.  
  7706.  SSYacc0002e         An invalid parse table was detected. 
  7707.  
  7708.  SSYacc0003e         An invalid parse table was detected. 
  7709.  
  7710.  SSYacc0004e         An invalid index was specified on elementFromProduction. 
  7711.  
  7712.  SSYacc0005e         Unexpected end of input detected. 
  7713.  
  7714.  SSYacc0006e         Error recovery failed, no usable state could be located. 
  7715.  
  7716.  SSYacc0007e         Error recovery failed, no recovery token could be located. 
  7717.  
  7718.  SSYacc0008e         Error panic recovery procedure could not locate a valid 
  7719.                      token in the current context. 
  7720.  
  7721.  SSYacc0009e         The rule file name was missing on the SSPARSE command. 
  7722.  
  7723.  SSYacc0010e         The start symbol was not a nonterminal symbol. Use the 
  7724.                      Symbol File to help resolve the error. 
  7725.  
  7726.  SSYacc0011e         The leftside symbol was not a nonterminal symbol. Use the 
  7727.                      Symbol File to help resolve the error. 
  7728.  
  7729.  SSYacc0012e         The production label name was duplicated.  Production 
  7730.                      label names must be unique. 
  7731.  
  7732.  SSYacc0013e         The regular expression was invalid.  A preceding message 
  7733.                      describes the error in more detail. 
  7734.  
  7735.  SSYacc0014e         No %expression lists were included in the rule file.  A 
  7736.                      rule file must have at least 1 %expression list. 
  7737.  
  7738.  SSYacc0015e         A syntax error was detected.  The valid lookahead symbols 
  7739.                      are listed in the message.  Very often, this is the result 
  7740.                      of a missing ';'. 
  7741.  
  7742.  SSYacc0017e         The precedence specified was to large.  It must be less 
  7743.                      than 0xfffffffe. 
  7744.  
  7745.  SSYacc0018e         An invalid name or alias was specified in a %prec section. 
  7746.                      The name or alias could not be located in an %expression 
  7747.                      list. 
  7748.  
  7749.  SSYacc0019e         The precedence specified was to large.  It must be less 
  7750.                      than 0xfffffffe. 
  7751.  
  7752.  SSYacc0020e         The precedence entry is a duplicate.  Only one entry may 
  7753.                      be specified for each %expression list entry. 
  7754.  
  7755.  SSYacc0021e         A different alias name was specified for the same name in 
  7756.                      a %expression list entry.  You cannot have 2 different 
  7757.                      aliases for the same token. 
  7758.  
  7759.  SSYacc0022e         The alias name was the same as a previous alias name, but 
  7760.                      the name was different.  You cannot have the same alias on 
  7761.                      2 different tokens. 
  7762.  
  7763.  SSYacc0023e         The production is unreachable.  This is usually the result 
  7764.                      of a misspelled nonterminal name. Use the Symbol File to 
  7765.                      help resolve the error. 
  7766.  
  7767.  SSYacc0024e         The production is never derives a token string. This is 
  7768.                      usually the result of a misspelled nonterminal name. Use 
  7769.                      the Symbol File to help resolve the error. 
  7770.  
  7771.  SSYacc0025e         A shift/reduce conflict was detected in the grammar.  Use 
  7772.                      the Yacc Machine File to help resolve the error.  You can 
  7773.                      also use the graphical debugger with grammars containing 
  7774.                      shift/reduce conflicts.  When a conflict is reached, you 
  7775.                      must reslove the conflict with a mouse click. 
  7776.  
  7777.  SSYacc0026e         Same as SSYacc0025e 
  7778.  
  7779.  SSYacc0027e         A reduce/reduce conflict was detected in the grammar.  Use 
  7780.                      the Yacc Machine File to help resolve the error.  You can 
  7781.                      also use the graphical debugger with grammars containing 
  7782.                      reduce/reduce conflicts.  When a conflict is reached, you 
  7783.                      must reslove the conflict with a mouse click. 
  7784.  
  7785.  SSYacc0028e         Same as SSYacc0027e 
  7786.  
  7787.  SSYacc0029e         This is like a reduce/reduce conflict, except the accept 
  7788.                      state is involved in the conflict. 
  7789.  
  7790.  SSYacc0030e         There were errors in your rule file specification. 
  7791.  
  7792.  SSYacc0031e         There were errors in your rule file specification. 
  7793.  
  7794.  SSYacc0032e         There were errors in your rule file specification. 
  7795.  
  7796.  SSYacc0033e         The rule file name was missing on the SSPARSE command. 
  7797.  
  7798.  SSYacc0034e         The start symbol could not be found. Use the Symbol File 
  7799.                      to help resolve the error. 
  7800.  
  7801.  SSYacc0035e         The start symbol must be a nonterminal. Use the Symbol 
  7802.                      File to help resolve the error. 
  7803.  
  7804.  SSYacc0037e         The %expression list name was duplicated.  Each name on an 
  7805.                      %expression list must be unique. 
  7806.  
  7807.  SSYacc0038e         A %push name was encountered, but no corresponding 
  7808.                      %expression list name could be located. 
  7809.  
  7810.  SSYacc0039e         An expression list was defined, but never referenced. 
  7811.  
  7812.  SSYacc0040e         A null quoted expression was detected.  There must be at 
  7813.                      least 1 character inside a quoted expression. 
  7814.  
  7815.  SSYacc0041e         The error panic recovery procedure failed, no valid token 
  7816.                      could be located. 
  7817.  
  7818.  SSYacc0042e         An %error or % token followed by a %error % token is 
  7819.                      redundant and not allowed. 
  7820.  
  7821.  SSYacc0043e         You are using the demo version and specified too many 
  7822.                      regular expressions. 
  7823.  
  7824.  SSYacc0044e         You are using the demo version and specified too many 
  7825.                      productions. 
  7826.  
  7827.  SSYacc0101e         A file could not be opened. 
  7828.  
  7829.  SSYacc0102e         An invalid table was detected. 
  7830.  
  7831.  SSYacc0103e         An attempt was made to read past eof. 
  7832.  
  7833.  SSYacc0104e         The error panic recovery procedure failed, no token could 
  7834.                      be located. 
  7835.  
  7836.  SSYacc0105e         Error recovery failed, no token could be located. 
  7837.  
  7838.  SSYacc0106e         Error recovery reached end of data before a valid token 
  7839.                      was located. 
  7840.  
  7841.  SSYacc0107e         An invalid parse table was detected. 
  7842.  
  7843.  SSYacc0108e         An invalid index was specified on elementFromProduction. 
  7844.  
  7845.  SSYacc0109e         The parse table is missing. Each parser requires a parse 
  7846.                      table. 
  7847.  
  7848.  SSYacc0110e         A lexer is required by each parser, or you must override 
  7849.                      the nextLexeme virtual function. 
  7850.  
  7851.  SSYacc0111e         An error occurred while reading the parse table. 
  7852.  
  7853.  SSYacc0112e         The parse table is too big. 
  7854.  
  7855.  SSYacc0113e         A permanent error was detected, but you tried to continue 
  7856.                      parsing. 
  7857.  
  7858.  SSYaccOutIn0002e    You continued parsing even though the data was detected. 
  7859.