diff options
Diffstat (limited to 'support/splint/examples/symbols/symmap.sty')
-rw-r--r-- | support/splint/examples/symbols/symmap.sty | 71 |
1 files changed, 58 insertions, 13 deletions
diff --git a/support/splint/examples/symbols/symmap.sty b/support/splint/examples/symbols/symmap.sty index 12261be656..450dd9a649 100644 --- a/support/splint/examples/symbols/symmap.sty +++ b/support/splint/examples/symbols/symmap.sty @@ -1,4 +1,4 @@ -% Copyright 2012-2014, Alexander Shibakov +% Copyright 2012-2020, Alexander Shibakov % This file is part of SPLinT % % SPLinT is free software: you can redistribute it and/or modify @@ -54,17 +54,15 @@ \input cweb/gyytab.tex % this should be the parser that will be used later % in this case it is just an example \edef\tointermediateparser{% - \noexpand\savefullstate % unnecessary - \noexpand\savefullstateextra % unnecessary \let\noexpand\parsernamespace\noexpand\inamespace % switch to the new namespace \the\pinittoks % restore all the tables, tokens and constants, and stacks \let\noexpand\getcurrentparser\noexpand\tointermediateparser }% - \settokens % this simply assign values to tokens where the name of each token is taken out of yytname ... - \input \drvname.tok % this will set up token equivalences in the namespace above ... - % those are the values gleaned during the bootstrapping stage. - % in the general case, one needs to run a bootsrapping (or similar) - % parser to extract the token information. + \settokens % this simply assigns values to tokens where the name of each token is taken out of yytname ... + \input bo.tok % this will set up token equivalences in the namespace above ... + % those are the values gleaned during the bootstrapping stage. + % in the general case, one needs to run a bootsrapping (or similar) + % parser to extract the token information. \optimizeall % this is necessary for correct rule listing in the output stage: % otherwise \fgetelemof will use the current value of the \yy... token registers which % will hold the values of the full parser that is loaded next @@ -72,7 +70,7 @@ \listrules % ... to be used while listing the rules % note that we do not bother to set up a lexer for this parser (even though we already have one and the % \optimizeall macro above will create a set of associative tables for it---this is merely an unwanted - % sideffect); after the rules have been listed, the intemediate parser in no longer needed. + % sideffect); after the rules have been listed, the intemediate parser is no longer needed. %\showthe\newsymswitch \def\fullnamespace{[full]}% this is the parser that parses the bison grammar from a raw % bison file; it can play a role of the bootstrap parser for @@ -96,7 +94,7 @@ % part of the file, this can simply be disabled \settokens \setflexstates % the main lexer can be reused in this case; the states still need to be set up - \input \drvname.tok % set up the tokens for the bison grammar parser + \input bo.tok % set up the tokens for the bison grammar parser \newparserstate \newlexerstate \newlexerstateextra @@ -104,8 +102,6 @@ \setnulstack{yyirulestack}% % \edef\tofullparser{% - \noexpand\savefullstate - \noexpand\savefullstateextra \let\noexpand\parsernamespace\noexpand\fullnamespace % switch to the new namespace \the\pinittoks % restore all the tables, tokens and constants, and stacks \let\noexpand\getcurrentparser\noexpand\tofullparser @@ -140,7 +136,7 @@ \fi }% % build the command to create the symbolic name switch - \toksc{\tofullparser\parserinit + \toksc{\tofullparser\basicparserinit\bisonparserinit\bisonparserdatainit \let\yyinputold\yyinput \let\yyinput\yyinputtrivial % a demo of a stripped down, slightly faster input routine \doascii{11}\expandafter\yyparse}% @@ -161,4 +157,53 @@ {\newlinechar=`\^^J \immediate\write\symbolicswitch{\the\setsncommands\the\unsetsncommands}}% \immediate\closeout\symbolicswitch \tomainparser % go back to the main parser +% +% \flex\ parser test +% + {% + \toflexreparser + \basicparserinit + \flexreparserinit + \flexreparserdatainit + \yyBEGIN{SECT2}% + \flin@ruletrue + % special status of `\yl' in \CWEB\ makes the following workaround necessary + % if the code is unsed inside a \CWEB\ file + %|@t}\expandafter\yyparse\space [a-b]*(c|d|e)?\yyeof\yyeof\endparseinput\endparse{@>| + \expandafter\yyparse\space [a-b]*(c|d|e)?\yyeof\yyeof\endparseinput\endparse + \ifyyparsefail\else + \ferrmessage{done processing flex}% + \fi + }% +% + {% + \def\flnamespace{[flex]} + \let\parsernamespace\flnamespace + \toflexparser + \basicparserinit + %\flexparserinit + \flexparserdatainit + \yylessusedtrue % TODO: put it in the \genericparser command + \let\f@nishparse\finishparse + \def\finishparse{\endinput\message{end of input}\relax\let\cleanupcs\f@nishparse}% + \def\next{% + \catcode`\\=12 + \catcode`\^^J=12 + \catcode`\%=12 + \catcode`\^^M=12 + \catcode`\{=12 + \catcode`\}=12 + \catcode`\#=12 + \catcode`\_=12 + %\yydebugmost + \expandafter\yyparse\input cweb/lo.l \cleanupcs\yyeof\yyeof\endparseinput\endparse % note that the space after the file name is necessary + \ifyyparsefail + \errmessage{stopped}% + \fi + \yydebugnone + \basicparserinit + \expandafter\yyparse\input cweb/fil.l \cleanupcs\yyeof\yyeof\endparseinput\endparse + % note that the space after the file name is necessary + }\expandafter\next % to lock the \catcode of the brace + }% \fi |