Skip to main content

module lang::cobol85::\syntax::Layout

rascal-0.43.3
org.rascalmpl.cobol-air-0.1.2

Whitespace, separators, comment lines and the preprocessed margins of fixed-format COBOL source.

Usage​

import lang::cobol85::\syntax::Layout;

This module defines the layout that the parser skips between tokens: spaces, tabs and newlines, the separator comma and semicolon, comment lines (a * or / in the indicator column), and the margins. The preprocessor replaces the sequence number area (columns 1-6) and the identification area (from column 73) by U+E000, one code point per column, so source offsets stay the same and the margins can be recognized as comment layout; this is why an editor shows the original sequence numbers as comments. The module also accepts the - indicator of a continuation line as layout. Every other module builds on this one, so any lexical or restriction elsewhere that looks for whitespace must accept U+E000 as well.

syntax LAYOUTLIST​

layout LAYOUTLIST = LAYOUT* !>> [\t-\n\ ,;\uE000];

syntax LAYOUT​

lexical LAYOUT
= @category="comment" ^"\uE000\uE000\uE000\uE000\uE000\uE000*" ![\n]* !>> ![\n]$
| @category="comment" ^"\uE000\uE000\uE000\uE000\uE000\uE000/" ![\n]* !>> ![\n]$
// the indicator of a continuation line; its left margin is the margin alternative below, like on any other line
| [\uE000] << "-"
| [\t-\n\ ;,]
// the margins; the editor shows the original sequence numbers and identification texts there, as comments
| @category="comment" [\uE000]+ !>> [\uE000]
;