1010# This implies all whitespace except newlines, including trailing whitespace, is part
1111# of the sequence.
1212machine = let
13- re = Automa. RegExp
14-
1513 hspace = re " [ \t\v ]"
1614 newline = let
17- lf = re "\n "
18- lf. actions[:enter ] = [:countline ]
19- re. opt (' \r ' ) * lf
15+ lf = onenter! (re "\n " , :countline )
16+ Re. opt (' \r ' ) * lf
2017 end
2118 space = hspace | newline
2219
2320 # Identifier: Leading non-space
24- identifier = re. rep (re. any () \ re. space ())
25- identifier. actions[:enter ] = [:mark ]
26- # Action: Store length of identifier
27- identifier. actions[:exit ] = [:identifier ]
21+ identifier = onexit! (onenter! (Re. rep (Re. any () \ Re. space ()), :mark ), :identifier )
2822
2923 # Description here include trailing whitespace.
3024 # This is needed for the FSM, since the description can contain arbitrary
3125 # whitespace, the only way to know the description ends is to encounter a newline.
3226 # NB: Make sure to also change the Index machine to match this is you change it.
33- description = identifier * re. opt (hspace * re " [^\r\n ]*" )
34-
35- # Action: Store length of description and append description to record.data
36- description. actions[:exit ] = [:description ]
27+ description = onexit! (identifier * Re. opt (hspace * re " [^\r\n ]*" ), :description )
3728
3829 # Header: '>' then description
3930 header = re " >" * description
4031
4132 # Sequence line: Anything except \r, \n and >
42- # Note: Must be consistent with the ByteSet in reader.jl used for seeking
43- sequence_line = re " [^\n\r >]+"
44- sequence_line. actions[:enter ] = [:mark ]
45- # Action: Append letters to sequence_line
46- sequence_line. actions[:exit ] = [:seqline ]
33+ # Note: Must be consistent with the disallowed bytes in reader.jl used for seeking
34+ sequence_line = onexit! (onenter! (re " [^\n\r >]+" , :mark ), :seqline )
4735
4836 # Sequence: This is intentionally very liberal with whitespace.
4937 # Any trailing whitespace is simply considered part of the sequence.
5038 # Is this bad? Maybe.
51- sequence = re . rep1 (re . opt (sequence_line) * re . rep1 (newline))
39+ sequence = Re . rep1 (Re . opt (sequence_line) * Re . rep1 (newline))
5240
5341 # We have sequence_eof to allow the final sequence to not end in whitespace
54- sequence_eof = re . opt (sequence_line) * re . rep (re . rep1 (newline) * re . opt (sequence_line))
42+ sequence_eof = Re . opt (sequence_line) * Re . rep (Re . rep1 (newline) * Re . opt (sequence_line))
5543
56- record = header * newline * sequence
57- record. actions[:exit ] = [:record ]
58- record_eof = header * newline * sequence_eof
59- record_eof. actions[:exit ] = [:record ]
44+ record = onexit! (header * newline * sequence, :record )
45+ record_eof = onexit! (header * newline * sequence_eof, :record )
6046
61- fasta = re . rep (space) * re . rep (record) * re . opt (record_eof)
47+ fasta = Re . rep (space) * Re . rep (record) * Re . opt (record_eof)
6248
6349 Automa. compile (fasta)
6450end
10692
10793returncode = :(return cs, linenum, found)
10894
109- Automa. Stream . generate_reader (
95+ Automa. generate_reader (
11096 :readrecord! ,
11197 machine,
11298 arguments = (:(record:: Record ), :(state:: Tuple{Int,Int} )),
@@ -120,7 +106,7 @@ Automa.Stream.generate_reader(
120106validator_actions = Dict (k => quote nothing end for k in keys (actions))
121107validator_actions[:countline ] = :(linenum += 1 )
122108
123- Automa. Stream . generate_reader (
109+ Automa. generate_reader (
124110 :validate_fasta ,
125111 machine,
126112 arguments = (),
0 commit comments