Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow reserved words as record names w/out quotes #7873

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Commits on Sep 11, 2024

  1. Allow reserved words as record names w/out quotes

    This motivation for this comes from the Nitrogen Web Frameworks's heavy
    use of records, and a clash between HTML <div> element and the Erlang
    div operator.
    
    In Nitrogen, HTML elements are represented by Erlang records. For
    example: the HTML `<span>` element is `#span{}` in Nitrogen.
    
    Logically, the heavily-used HTML `<div>` element would be represented
    by `#div{}` in Nitrogen, however, that specific syntax is illegal due to
    `div`'s reserved word status, and must instead be represented with
    `#'div'`. This syntax, however, is awkward, and has led to a workaround
    that *works*, but is itself awkward (using the term `#panel{}` instead
    of `#div{}` - but this in itself leads to a semantic clash, as some
    frontend HTML frameworks have their own 'panel' elements that might
    ideally be abstracted into a `#panel{}` element.
    
    But, As far as I understand, there is no potential syntax clash in
    allowing the syntax `#div` ito be acceptable, and have the parser
    recognize that the `div` (or any reserved word) in that `context` can
    only be an atom, and would never be an operator.
    
    So this change tweaks the grammar to recognize the circumstances of:
    `#reserved_word{}`.
    
    Further, this change does not change the way the records are defined (so
    the definition must still be defined with the atom properly wrapped in
    quotes (e.g. `-record('div', {a,b}).`).
    
    This PR also adds the appropriate tests in `erl_expand_records_SUITE`,
    which I wasn't sure if that was appropriate place, but it seemed the
    most relevant.
    choptastic authored and RaimoNiskanen committed Sep 11, 2024
    Configuration menu
    Copy the full SHA
    06262ae View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    dde9f78 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    2b0e1ca View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    7af6208 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    d9429e7 View commit details
    Browse the repository at this point in the history

Commits on Sep 13, 2024

  1. Configuration menu
    Copy the full SHA
    f45d691 View commit details
    Browse the repository at this point in the history

Commits on Sep 16, 2024

  1. Configuration menu
    Copy the full SHA
    539299e View commit details
    Browse the repository at this point in the history