Class: Expressir::Express::RemarkScanner
- Inherits:
-
Object
- Object
- Expressir::Express::RemarkScanner
- Defined in:
- lib/expressir/express/remark_scanner.rb
Overview
Scans EXPRESS source text and extracts all remarks (tail and embedded),
correctly tracking embedded-remark nesting so that inline -- inside
a (* ... *) documentation block is NOT mistaken for a tail remark.
Single responsibility: source string -> Array
Reference: ISO 10303-11 §7.1.6.
tail_remark = '--' [ remark_tag ] {
The scanner is a single-pass state machine with three states:
:top — outside any remark; look for `--` or `(*`.
:in_tail — inside a tail remark; look only for the next newline.
:in_embedded — inside one or more nested embedded remarks; look
for the matching `*)` or a nested `(*`, ignoring `--`.
Defined Under Namespace
Classes: Remark
Constant Summary collapse
- TAIL_FORMAT =
Format discriminator values.
"tail"- EMBEDDED_FORMAT =
"embedded"- TAIL_MARKER =
Lexical markers recognised by EXPRESS.
"--"- EMBEDDED_OPEN =
"(*"- EMBEDDED_CLOSE =
"*)"- INFORMAL_PROPOSITION_TAG =
Tag forms (see ISO 10303-11 §7.1.6.3 Remark tag). IP-style informal-proposition tags are recognised only in tail remarks (matching historic behaviour); embedded remarks use the quoted form.
/\A(IP\d+):\s*(.*)\z/m- QUOTED_TAG =
/\A"([^"]*)"\s*(.*)\z/m
Instance Method Summary collapse
-
#initialize(source) ⇒ RemarkScanner
constructor
A new instance of RemarkScanner.
-
#scan ⇒ Array<Remark>
(also: #call)
Returns an Array of Remark, in source order (by byte position).
Constructor Details
#initialize(source) ⇒ RemarkScanner
Returns a new instance of RemarkScanner.
55 56 57 58 59 |
# File 'lib/expressir/express/remark_scanner.rb', line 55 def initialize(source) @source = source @source_bytes = source.b @line_map = LineMap.new(@source_bytes) end |