Opened 14 months ago

Last modified 12 months ago

#370 closed enhancement

Enhancements for the reductions Command (version 3.0) — at Initial Version

Reported by: Gary Dixon Owned by: Eric Swenson
Priority: major Milestone: MR12.9
Component: Tools Version: MR12.6e
Keywords: Cc:

Description

Input source to the reductions (rdc) command must be parsed into tokens that can be analyzed by reductions command. Up to this point, only the lex_string_.pl1 subroutine has been available for this parsing. It parses an input string into character-string tokens separated by break characters. Each token is described by a token descriptor structure declared in lex_descriptors_.incl.pl1.

A new parser in being proposed as part of enhancements to the ssu_ subsystem. ssu_$get_tokens will parse an input segment into tokens that describe several higher-level constructs:

  • character tokens (similar to those of lex_string_).
  • pl1 quoted character-string tokens surrounded by double-quote (") characters.
  • pl1 quoted bit-string tokens surrounded by double-quote (") characters and ending with a radix suffix (b or b1, b2, b3, b4) specifying digits within quotes to be binary, quaternary, octal or hexadecimal.
  • lists of tokens coming in four flavors.
    • parenthesized list surrounded by left/right parenthesis characters: ( ... )
    • square-bracket list surrounded by left/right bracket characters: [ ... ]
    • braced list surrounded by left/right brace characters: { ... }
    • angle-bracket list surrounded by less-than (<) and greater-than (>) characters: < ... >

ssu_$get_tokens will generate a threaded list of token descriptors as declared in ssu_token.incl.pl1. These token structures have almost the same elements as those produced by lex_string_. The two varieties of token structure will have the same storage footprint (same length in words); the same layout for shared elements describing start and length of the described character string and its line number in the source string, etc. Structures from ssu_$get_tokens will add elements beyond those of lex_string_ within formerly reserved spaces within the token structure declaration.

While the reductions command and its reduction_compiler_.rd subroutine will treat all tokens as if they were generated by lex_string_, an input source (XXX.rd) using ssu_$get_tokens variety needs to reference the token structure described by ssu_token.incl.pl1. To support this dual overlay for the token data, the XXX.rd source program needs to be divided into two sections.

  • The part that defines the reduction statements and provides syntax and semantic subroutines named in those reductions will reference the token structure as declared in ssu_token.incl.pl1.
  • The SEMANTIC_ANALYSIS subroutine generated by the reductions compiler will reference those same tokens using the token structure as declared in lex_descriptors_.incl.pl1.

The reductions command needs to be told which form of tokens to expect.
Add a new Reduction Attribute Statement:

VERSION n \

where n is 2 for tokens from lex_string; or 3 for tokens from ssu_$get_tokens.

The reductions command can then produce a slightly different source when it generates the SEMANTIC_ANALYSIS subroutine which analyzes the incoming tokens. For VERSION 3, this subroutine will include the lex_descriptor_.incl.pl1 segment only within the scope of that SEMANTIC_ANALYSIS subroutine. The other part of the XXX.rd source program can have its own declaration of the token structure (via use of an %include ssu_token; macro) to reference the tokens provided by ssu_$get_tokens subroutine. Its syntax and semantic routines can then access the extra elements describing the new style of token generated by ssu_$get_tokens.

Additional Fixes

While enhancing the reductions command, several minor problems should be repaired.

The rdc_XXX_.incl.pl1 segments have header comments that use underlined words for emphasis. While 1970s computer terminals and printers properly handled such underlined text, today's video terminals only display them as a sequence of characters separated by backspace (BS) characters; these BS chars caused overstrikes of a single character position on the printed line.

  1. The use of underlined words should be removed from comments in the rdc_XXX_.incl.pl1 segments to make those comments more legible on video terminals.

The version 1 pl1 compiler did not support use of a %page; macro to separate sections of the .pl1 source program from one another. Today's version 2 pl1 does support this macro.

  1. Change both reduction_compiler_.rd and the various rdc_XXX_.incl.pl1 segments it inserts to use a %page; macro to insert page breaks. These would replace use of a new page (\014) character in the .pl1 source lines generated by reduction_compiler_.rd, or included in the rdc_XXX_.incl.pl1 segments.

When the reductions command translates an XXX.rd describing a new language into an XXX.pl1 source program that can analyze statements in the new language, it outputs a header describing the version of reductions command that generated the analyzer, date and time of generation, etc. Existence of this header followed conventions of existing translators of the time by documenting these translation details at the top of the .list file. However, the reductions command just inserts a PL/I comment string atop the user-supplied XXX.rd text, and lets the pl1 command then generate a .list if one is requested.

Unfortunately, this extra comment at the top of the XXX.pl1 source means that any problems found by the pl1 compiler in the XXX.rd lines that follow that comment are reported with a line number that does not match position of the offending source line in the XXX.rd segment submitted to the reductions command. The shift in line numbers within pl1 error statements can be avoided by adding a feature to the reductions command.

  1. If the XXX.rd segment containing reduction statements begins with 10 blank lines (10 consecutive newline (NL) characters), then the reductions command can replace those 10 blank lines with its PL/I comment documenting reductions version, date/time of translation, etc. Then line numbers will be the same in both XXX.rd and XXX.pl1 segments.

An ambiguity exists in control arguments accepted by the reductions command. Its existing -trace {on|off} control argument adds a trace facility to the generated language analyzer, with tracing either turned on by default, or turned off by default. But since the reductions command uses reduction statements to analyze each input reduction statement in the XXX.rd source program, there may be a need to turn on/off that tracing feature in the executing reductions program.

  1. Add new -tracing and -no_tracing control arguments to the reductions command to control tracing of reductions in the reductions compiler while it is executing. The existing -trace {on|off} can be used to specify whether to add a similar tracing facility to the generated analyzer program.

Change History (0)

Note: See TracTickets for help on using tickets.