diff options
Diffstat (limited to 'support/splint/examples/ld/ldnp.w')
-rw-r--r-- | support/splint/examples/ld/ldnp.w | 71 |
1 files changed, 52 insertions, 19 deletions
diff --git a/support/splint/examples/ld/ldnp.w b/support/splint/examples/ld/ldnp.w index f92d0dfc8c..0a99d864fd 100644 --- a/support/splint/examples/ld/ldnp.w +++ b/support/splint/examples/ld/ldnp.w @@ -1,4 +1,4 @@ -@q Copyright 2012-2015, Alexander Shibakov@> +@q Copyright 2012-2020, Alexander Shibakov@> @q This file is part of SPLinT@> @q SPLinT is free software: you can redistribute it and/or modify@> @@ -40,7 +40,7 @@ initialization is done by the macros below. After the initialization has been completed, the switch command is replaced by the one that activates the new name parser. @<Modified name parser for \ld\ grammar@>= -@G +@G(t) \genericparser name: ldsmall, ptables: ld_small_tab.tex, @@ -48,10 +48,12 @@ activates the new name parser. tokens: {}, asetup: {}, dsetup: {}, - rsetup: {\noexpand\savefullstateextra}, + rsetup: \let\returnexplicitspace\ignoreexplicitspace, % ignore spaces in names optimization: {};% \let\otosmallparser\tosmallparser % /* save the old name parser */ \let\tosmallparser\toldsmallparser +\expandafter\let\csname to\stripbrackets\cwebclinknamespace parser\endcsname\tosmallparser % +/* make the name parser handle the typesetting of \Cee\ variables */ @g @ @<Bison options@>= @@ -70,6 +72,7 @@ activates the new name parser. %token INTEGER %token EXTENDED %token WILDCARD +%token META_IDENTIFIER @g @*1 The name parser productions. These macros do a bit more than we @@ -80,26 +83,39 @@ order to be able to refer to, say, \flex\ options in text. The inline action in one of the rules for \prodstyle{identifier\_string} was added to adjust the number and the position of the terms so that the appropriate action can be reused later for -\prodstyle{qualified\_identifier\_string}. +\prodstyle{qualified\_identifier\_string}. +%\tracebadnamestrue +%\tracenamestrue +%\traceparserstatestrue +%\tracestackstrue +%\tracerulestrue +%\traceactionstrue +%\tracelookaheadtrue +%\traceparseresultstrue +%\tracebadcharstrue +%\yyflexdebugtrue @<Parser productions@>= @G full_name: identifier_string suffixes.opt {@> @<Compose the full name@> @=} | qualifier '_' identifier_string suffixes.opt {@> @<Compose a qualified name@> @=} +| META_IDENTIFIER {@> @<Turn a \prodstylens{META\_IDENTIFIER}{\ldsmallnamespace} into a full name@> @=} +| '\'' {@> @<Make \prodstyle{'} into a name@> @=} ; identifier_string: PERCENT_IDENTIFIER {@> @<Attach option name@> @=} | IDENTIFIER {@> @<Start with an identifier@> @=} | '\'' WILDCARD '\'' {@> @<Start with a quoted string@> @=} +| '\'' '_' '\'' {@> @<Start with a \prodstyle{'\_'} string@> @=} | '\'' '.' '\'' {@> @<Start with a \prodstyle{'.'} string@> @=} -| '\'' '_' '\'' {@> @<Start with an \prodstyle{'\_'} string@> @=} @t}\vb{\flatten}{@> | incomplete_identifier_string {} IDENTIFIER {@> @<Attach an identifier@> @=} ; @t}\vb{\resetf}{@> incomplete_identifier_string: - identifier_string '_' {@> TeX_( "/yy0{/the/yy(1)}" ); @=} + '_' {@> TeX_( "/yy0{/nx/idstr{}{}}" );@=} +| identifier_string '_' {@> TeX_( "/yy0{/the/yy(1)}" ); @=} | qualified_identifier_string '_' {@> TeX_( "/yy0{/the/yy(1)}" ); @=} ; @@ -144,7 +160,16 @@ qualifier: @[TeX_( "/yy0{/the/yy(1)/the/yy(2)}/namechars/yyval" );@]@; @ @<Compose a qualified name@>= - @[TeX_( "/yy0{/the/yy(3)/the/yy(4)/nx/dotsp/nx/qual/the/yy(1)}/namechars/yyval" );@]@; + @[TeX_( "/getfirst{/yy(1)}/to/toksa/getsecond{/yy(1)}/to/toksb" );@]@; + @[TeX_( "/yy0{/the/yy(3)/the/yy(4)/nx/dotsp/nx/qual{/the/toksa/nx/_}{/the/toksb/uscoreletter}}/namechars/yyval" );@]@; + +@ @<Turn a \prodstylens{META\_IDENTIFIER}{\ldsmallnamespace} into a full name@>= + @[TeX_( "/getfirst{/yy(1)}/to/toksa" );@]@; + @[TeX_( "/getsecond{/yy(1)}/to/toksb" );@]@; + @[TeX_( "/yy0{/nx/idstr{/the/toksa}{/the/toksb}}/namechars/yyval" );@]@; + +@ @<Make \prodstyle{'} into a name@>= + @[TeX_( "/yy0{/nx/chstr{'}{'}}/namechars/yyval" );@]@; @ @<Attach option name@>= @[TeX_( "/getfirst{/yy(1)}/to/toksa" );@]@; @@ -164,13 +189,13 @@ qualifier: @ @<Start with a quoted string@>= @[TeX_( "/getfirst{/yy(2)}/to/toksa" );@]@; @[TeX_( "/getsecond{/yy(2)}/to/toksb" );@]@; - @[TeX_( "/yy0{/nx/chstr{/the/toksa}{/the/toksb}}" );@]@; + @[TeX_( "/yy0{/nx/visflag{/nx/termvstring}{}/nx/chstr{/the/toksa}{/the/toksb}}" );@]@; -@ @<Start with a \prodstyle{'.'} string@>= - @[TeX_( "/yy0{/nx/chstr{.}{.}}" );@]@; +@ @<Start with a \prodstyle{'\_'} string@>= + @[TeX_( "/yy0{/nx/visflag{/nx/termvstring}{}/nx/chstr{/nx/_}{_}}" );@]@; -@ @<Start with an \prodstyle{'\_'} string@>= - @[TeX_( "/yy0{/nx/chstr{/uscoreletter}{/uscoreletter}}" );@]@; +@ @<Start with a \prodstyle{'.'} string@>= + @[TeX_( "/yy0{/nx/visflag{/nx/termvstring}{}/nx/chstr{.}{.}}" );@]@; @ @<Turn a qualifier into an identifier@>= @<Start with an identifier@>@; @@ -193,10 +218,12 @@ qualifier: @[TeX_( "/yy0{/nx/dotsp/nx/sfxi/the/yy(1)}" );@]@; @ @<Attach a subscripted integer@>= - @[TeX_( "/yy0{/nx/dotsp/nx/sfxi/the/yy(2)}" );@]@; + @[TeX_( "/getfirst{/yy(2)}/to/toksa/getsecond{/yy(2)}/to/toksb" );@]@; + @[TeX_( "/yy0{/nx/dotsp/nx/sfxi{/nx/_/the/toksa}{/uscoreletter/the/toksb}}" );@]@; @ @<Attach a subscripted qualifier@>= - @[TeX_( "/yy0{/nx/dotsp/nx/qual/the/yy(2)}" );@]@; + @[TeX_( "/getfirst{/yy(2)}/to/toksa/getsecond{/yy(2)}/to/toksb" );@]@; + @[TeX_( "/yy0{/nx/dotsp/nx/qual{/nx/_/the/toksa}{/uscoreletter/the/toksb}}" );@]@; @ @<Attach suffixes@>= @[TeX_( "/yy0{/nx/dotsp/the/yy(2)}" );@]@; @@ -262,10 +289,13 @@ void define_all_states( void ) { @ @<Lexer definitions@>= @<Lexer states@>@; -@G +@G(fs1) aletter [a-zA-Z] -wc ([^\\\']{-}[a-zA-Z0-9]|\\.) +letter (_|{aletter}) +wc ([^\\\'\"]{-}[_a-zA-Z0-9]|\\.) id ({aletter}|{aletter}({aletter}|[0-9])*{aletter}) +id_strict {letter}(({letter}|[-0-9])*{letter})? +meta_id "*"{id_strict}"*"? int [0-9]+ @g @@ -321,9 +351,8 @@ int [0-9]+ \tracebadcharsfalse \yyflexdebugfalse % -\yyskipparsetrue @<Scan white space@>= -@G +@G(fs2) [ \f\n\t\v] {@> @[TeX_( "/yylexnext" );@]@=} @g @@ -333,7 +362,7 @@ typesetting style for some of the keywords would need to be adjusted, such changes would be easy to implement, since the template is already here. @<Scan identifiers@>= -@G +@G(fs2) "%"({aletter}|[0-9]|[-_]|"%"|[<>])+ {@> @[TeX_( "/yylexreturnval{PERCENT_IDENTIFIER}" );@]@=} "opt" {@> @[TeX_( "/yylexreturnval{OPTIONAL}" );@]@=} @@ -344,6 +373,7 @@ here. {wc} {@> @[TeX_( "/yylexreturnval{WILDCARD}" );@]@=} {id} {@> @[@<Prepare to process an identifier@>@]@=} +{meta_id} {@> @[@<Prepare to process a meta-identifier@>@]@=} {int} {@> @[TeX_( "/yylexreturnval{INTEGER}" );@]@=} "\"" {@> @[TeX_( "/yylexnext" );@]@=} @@ -353,6 +383,9 @@ here. @ @<Prepare to process an identifier@>= @[TeX_( "/yylexreturnval{IDENTIFIER}" );@]@; +@ @<Prepare to process a meta-identifier@>= + @[TeX_( "/yylexreturnval{META_IDENTIFIER}" );@]@; + @ \let\hostparsernamespace\ldnamespace\yyskipparsefalse A simple routine to detect trivial scanning problems. @<React to a bad character@>= |