AngularDart directive expression grammar for mustache and other directives

What is the grammar of expressions that are allowed in AngularDart teachings {{...}}and other directives?

+4
source share
1 answer

Here is the EBNF grammar for AngularDart expressions, in the same notation as used in the Darts Programming Language Specification . These expressions may appear as arguments to Angular directives. While the grammar allows, for example, a list of expressions, assignments and conventions, separated by semicolons, they will not be accepted by all directives --- for example, it ng-clicksupports multiple expressions, possibly with an assignment, while the mustache directive {{...}}expects one expression.

expressions: expression (';' expressions)?
expression:
    literal
  | id args?                        # variable or function
  | expression '.' id args?         # member
  | expression '|' id filterArg*    # filter
  | expression '[' expression ']'
  | preOp expression
  | expression binOp expression
  | expression '?' expression ':' expression
  | expression '=' expression           # assignment
args: '(' expressionList? ')'
filterArg: ':' expression
expressionList: expression (',' expression)?
literal:
    'null'
  | stringLiteral
  | numberLiteral
  | boolLiteral
  | '[' expressionList? ']'
  | '{' (keyValuePair (',' keyValuePair)? )? '}'
keyValuePair:
  expression ':' expression

PreOp and binOp are mainly those supported by Darth (although I will have to double-check this). There is a more beautifully formatted version above here (I could not get MD to work together).

+2

Source: https://habr.com/ru/post/1524873/


All Articles