Blog

grammar notes

Here are notes on a medium-sized commit by jrose to clean up groovy.g.

Affected source files:

Functional changes

  • Uniformly turn supply the method name "call" to method calls lacking an explicit method name. So, foo(1)(2) is equivalent to foo(1).call(2).
  • Allow non-braced body statements on 'while' (plugin bug).
  • For compatibility, allow Java 5 for (T x : y) with a warning.
  • For compatibility, allow Java 5 assert x : y.
  • Put strictContextExpression more places for consistency.
  • Repair newline-suppression logic. Experimentally allow backslash '\' to force a newline to be insignificant outside of strings as well as inside.
  • Experimental: Tune newline-spanning logic (for f \n {g}) to be more selectively context-sensitive. (Affects pathExpression.)
    (Newline spanning is performed in a simple path expression or in the RHS of an assignment, but not within the subparts of a more complex expression. For example, it is not performed when parsing the arguments of a command. This rule is experimental and probably needs to be even more restrictive.)
  • Add mechanism to detect if an AST is simply a pathExpression.
  • Add mechanism to detect if an AST is a prefix of an expressionStatement.
    The inherited expression attribute lc_stmt tells if the left-context of an expression is a statement boundary or initializer.

Cleanups

  • Remove usless rule initializer.
  • Remove excessive lookahead in expressionStatement.
  • Get rid of (harmless) ANTLR warning.
grammar notes

Here are notes on a medium-sized commit by jrose to clean up groovy.g and associated files.

Affected source files:

Functional changes

  • Allow newline before LBRACE uniformly. Use nlsWarn in all such cases.
  • Factor T[] syntax into declaratorBrackets rule.
  • Make new and METHOD_CALL expressions have common structure.
  • Add grammar for proposed "$*x" GString syntax.
  • Right-exclusive ranges are spelled x..<y (x...y temporarily backward-compatible).
  • Fix bug in #! comment syntax.
  • Clarify keywords in argList rule. Allow '[:' only in grammar notes.

Name changes

  • SPREAD_ARG => SPREAD_DOT (for *. nodes)
  • OPTIONAL_ARG => OPTIONAL_DOT (for ?. nodes)
  • METHOD_POINTER => MEMBER_POINTER (for .& nodes)

Cleanups

  • Remove transitional hack arrayOrTypeArgs.
  • Clean up and simplify pathExpression and commandStatement rules.
  • Add some more javadoc.
  • Remove annoying zz= decorations on argList, etc.
  • Remove useless rules for expressionBlock, assignmentTail, assignmentOp.
  • Factor statement label syntax into statementLabelPrefix.
  • Remove some useless 'greedy' declarations.