Skip to content

More powerful list declarations #268

@andreasabel

Description

@andreasabel

We would like the following aspects supported by a feature that allows us to define lists:

  1. Concerning even AST:
    • several list categories for one category
    • non-empty vs. possibly empty lists
    • snoc (left associative) vs. cons (right associative) lists
  2. Concerning parsing:
    • delimiters (markers for begin and end)
    • separators (infix) vs. terminators (postfix) vs. "initiators" (prefix symbol, like bullet lists)
  3. Concerning printing:
    • horizontal vs. vertical (currently only for ";" separator/terminator)

A possible grammar for a new list pragma could be:

ListPragma. Def ::= "#list" Ident "of" Ident [ListAttribute] ;

ListAttribute 
  ::= "non-empty"
    | "snoc" | "cons"
    | "horizontal" | "vertical"
    | "open" String 
    | "close" String
    | {"prefix"|"postfix"}? "separator" String | "terminator" String | "initiator" String

Attributes listed on the same line are mutually exclusive.

How to print vertical lists?

separator-post = [
  a,
  b, 
  c ]
separator-pre = 
  [ a
  , b
  , c
  ]
separator-pre-without-delimiters =
  a
  + b
  + c
terminator = {
    a;
    b;
    c;
  }
initiator = begin
  - a
  - b
  - c
  end

The current automatic parsing of cons lists as snoc lists #163 would be removed, is anyway just a buggy optimization.
See also #106 for the delimiters syntax.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementlistsConcerning list categories and separator/terminator/delimiter pragmas

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions