On this page:
parse-all
8.17.0.6

5.1 Parsing🔗ℹ

 (require shrubbery/parse) package: shrubbery-lib

procedure

(parse-all in 
  [#:source source 
  #:mode mode 
  #:start-column start-column 
  #:variant variant]) 
  (or/c eof-object? syntax?)
  in : input-port?
  source : any/c = (object-name in)
  mode : (or/c 'top 'interactive 'line 'text) = 'top
  start-column : exact-nonnegative-integer? = 0
  variant : variant? = default-variant
Parses shrubbery notation from in and returns an S-expression representation as described in Parsed Representation as a syntax object.

The result syntax object has no scopes, but it has source-location information and raw text properties. See Source Locations and Raw-Text Properties for more information.

The default 'top mode reads in until an end-of-file, and it expects a sequence of groups that are indented consistently throughout (i.e., all starting at the same column). The result in 'top mode is always a multi representation. The 'text mode is similar, but it starts in “text” mode, as if the entire input is inside curly braces of an @ form (see At-Notation Using @). The result of 'text mode is always a brackets representation.

The 'interactive and 'line modes are similar to 'top. They are suitable for a read-eval-print loop or reading the continuation of a #lang shrubbery line, respectively. In both modes, reading stops when a newline is encountered, unless an opener remains to be closed or a : was encountered. If reading continues due to a :, then it stops when a blank line is found (where a line containing a comment does not count as blank). In 'line mode, the result may be empty, while 'interactive mode continues past a newline if the result would be empty.

The shrubbery parser directly determines line and column changes for the purposes of determining indentation, so it does not require in to have line counting enabled for that purpose. The start-column argument supplies a number of characters that should be considered before the first character of in for parsing. Source locations attached to the result syntax objects are based on positions reported by in or line and column counting as enabled for in.

The variant argument selects a variant of shrubbery notation to parse; see shrubbery/variant.