[Chapel Merge] Introduce unstable read/match/write methods for li

Branch: refs/heads/main
Revision: 4d5f6ab
Author: benharsh
Link: Unavailable
Log Message:

Merge pull request #20556 from benharsh/read-match-write-literal

Introduce unstable read/match/write methods for literals and newlines

This PR introduces new methods on channels to support reading and writing of literal strings, bytes, and newlines. The new methods, as discussed in #19487:

proc channel.readLiteral(literal:string, ignoreWhitespace=true) : void throws
proc channel.readLiteral(literal:bytes, ignoreWhitespace=true) : void throws
proc channel.readNewline() : void throws

// returns 'false' if literal could not be matched, or on EOF
proc channel.matchLiteral(literal:string, ignoreWhitespace=true) : bool throws
proc channel.matchLiteral(literal:bytes, ignoreWhitespace=true) : bool throws
proc channel.matchNewline() : bool throws

proc channel.writeLiteral(literal:string) : void throws
proc channel.writeLiteral(literal:bytes) : void throws
proc channel.writeNewline() : void throws

These methods will be marked as unstable for the time being until we can conclude a couple of questions:

  • What if a literal contains leading whitespace, and ignoreWhitespace is true (for read/match methods)?
  • Should the read/match newline methods contain an ignoreWhitespace=true argument?

[reviewed-by @mppf]

Modified Files:
A test/io/literals/match-literal.chpl

A test/io/literals/match-literal.compopts
A test/io/literals/match-literal.good
A test/io/literals/mismatch-read-write.chpl
A test/io/literals/mismatch-read-write.cleanfiles
A test/io/literals/mismatch-read-write.compopts
A test/io/literals/mismatch-read-write.prediff
A test/io/literals/mismatch-read-write.template.good
A test/io/literals/read-literal.chpl
A test/io/literals/read-literal.compopts
A test/io/literals/read-literal.good
A test/io/literals/utf8-literal-error.chpl
A test/io/literals/utf8-literal-error.good
A test/unstable/readMatchLiteral.chpl
A test/unstable/readMatchLiteral.good
M modules/standard/IO.chpl
M test/io/ferguson/readThis/readclass.chpl
M test/io/ferguson/readThis/readclass2.chpl
M test/io/ferguson/readThis/readclass3.chpl
M test/io/ferguson/recordeof.chpl
M test/io/recordio.chpl

Compare: https://github.com/chapel-lang/chapel/compare/ad593483f3ff...4d5f6abefa6f