blob: 9721976ac65f84c68cce1cc4c96f412bc51698ef [file] [log] [blame]
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
{
parserClass = "fuchsia.developer.plugin.fidl.parser.Parser"
extends = "com.intellij.extapi.psi.ASTWrapperPsiElement"
psiClassPrefix = "Fidl"
psiImplClassSuffix = "Impl"
psiPackage = "fuchsia.developer.plugin.fidl.psi"
psiImplPackage = "fuchsia.developer.plugin.fidl.psi.impl"
elementTypeHolderClass = "fuchsia.developer.plugin.fidl.psi.Types"
elementTypeClass = "fuchsia.developer.plugin.fidl.psi.ElementType"
tokenTypeClass = "fuchsia.developer.plugin.fidl.psi.TokenType"
// The FidlNamedElements identify the elements we want to appear in the structure view.
implements(".*-declaration")="fuchsia.developer.plugin.fidl.psi.FidlNamedElement"
implements("protocol-method|protocol-event|member-field")="fuchsia.developer.plugin.fidl.psi.FidlNamedElement"
extends(".*-declaration")="fuchsia.developer.plugin.fidl.psi.FidlNamedElementImpl"
extends("protocol-method|protocol-event|member-field")="fuchsia.developer.plugin.fidl.psi.FidlNamedElementImpl"
tokens = [
line_comment="regexp://.*"
]
}
file ::= library-header using-list? declaration-list
library-header ::= attribute-block? LIBRARY compound-identifier SEMICOLON
using-list ::= ( using SEMICOLON )*
using ::= USING_T compound-identifier ( AS identifier-token )?
compound-identifier ::= identifier-token ( DOT identifier-token )*
declaration-list ::= ( declaration SEMICOLON )*
declaration ::= const-declaration |
protocol-declaration |
layout-declaration |
type-alias-declaration |
resource-declaration |
service-declaration
declaration-modifiers ::= FLEXIBLE | STRICT | RESOURCE
const-declaration ::= attribute-block? CONST identifier-token type-constructor EQUALS constant
layout-declaration ::= attribute-block? TYPE identifier-token EQUALS inline-layout
inline-layout ::= attribute-block? ( declaration-modifiers )* layout-kind ( layout-subtype )? layout-body
layout-kind ::= BITS | ENUM | STRUCT | TABLE | UNION
layout-subtype ::= COLON type-constructor
layout-body ::= value-layout | struct-layout | ordinal-layout
value-layout ::= OBRACE ( value-layout-member SEMICOLON )+ CBRACE
// This declaration differs slightly from the master grammar in that it uses
// the definition of `constant`, rather than that named reference itself. This
// is for the benefit of the code in ContextAwareHighlighter.java, which must
// already traverse 3 steps up the ancestor chain (ie, the great grandparent of
// value-layout-member) in order to figure out the layout kind being analyzed.
// Putting `( compound-identifier | literal )` saves an extra step up the tree
// in that code.
value-layout-member ::= attribute-block? identifier-token EQUALS ( compound-identifier | literal )
struct-layout ::= OBRACE ( struct-layout-member SEMICOLON )* CBRACE
struct-layout-member ::= attribute-block? member-field
ordinal-layout ::= OBRACE ( ordinal-layout-member SEMICOLON )* CBRACE
ordinal-layout-member ::= attribute-block? ordinal COLON ( member-field | RESERVED )
protocol-declaration ::= attribute-block? PROTOCOL identifier-token
OBRACE ( protocol-member SEMICOLON )* CBRACE
protocol-member ::= protocol-method | protocol-event | protocol-compose
protocol-method ::= attribute-block? identifier-token parameter-list ( ARROW parameter-list ( ERROR type-constructor )? )?
protocol-event ::= attribute-block? ARROW identifier-token parameter-list
protocol-compose ::= COMPOSE compound-identifier
parameter-list ::= OPAREN ( type-constructor )? CPAREN
type-alias-declaration ::= attribute-block? ALIAS identifier-token EQUALS type-constructor
resource-declaration ::= attribute-block? RESOURCE_DEFINITION identifier-token COLON UINT32 OBRACE resource-properties CBRACE
resource-properties ::= PROPERTIES OBRACE ( member-field SEMICOLON )* CBRACE SEMICOLON
service-declaration ::= attribute-block? SERVICE identifier-token OBRACE ( service-member SEMICOLON )* CBRACE
service-member ::= attribute-block? member-field
member-field ::= identifier-token type-constructor
// Attributes are slightly different from master grammar for ease of parsing
attribute-block ::= doc-comments | attributes
doc-comments ::= ( DOC_COMMENT )+ attributes?
attributes ::= attribute*
attribute ::= AT identifier-token ( OPAREN attribute-signature CPAREN )?
attribute-signature ::= attribute-args | constant
attribute-args ::= attribute-arg ( COMMA attribute-arg )*
attribute-arg ::= identifier-token EQUALS constant
type-constructor ::= layout ( LANGLE layout-parameters RANGLE )? ( COLON type-constraints )?
layout ::= inline-layout | compound-identifier
layout-parameters ::= layout-parameter ( COMMA layout-parameter )*
layout-parameter ::= type-constructor | constant
type-constraints ::= type-constraint | ( LANGLE type-constraint ( COMMA type-constraint )* RANGLE )
type-constraint ::= constant
constant ::= compound-identifier | literal
ordinal ::= integral-literal
literal ::= STRING_LITERAL | numeric-literal | TRUE | FALSE
numeric-literal ::= DECIMAL_FLOAT_LITERAL | integral-literal
integral-literal ::= DECIMAL_INTEGRAL_LITERAL | HEX_INTEGRAL_LITERAL | BINARY_INTEGRAL_LITERAL
identifier-token ::= IDENTIFIER | ARRAY | AS | CHANNEL | CONST | ENUM | ERROR | EVENT | EVENTPAIR | FIFO |
GUEST | HANDLE | INTERFACE | INTERRUPT | JOB | LIBRARY | LOG | PORT | PROCESS |
REQUEST | RESERVED | RESOURCE | SOCKET | STRING | STRUCT | TABLE | THREAD |
TIMER | UNION | USING_T | VECTOR | VMAR | VMO | XUNION | BOOL | FLOAT32 |
FLOAT64 | INT8 | INT16 | INT32 | INT64 | UINT8 | UINT16 | UINT32 | UINT64 |
TRUE | FALSE | PROTOCOL | COMPOSE | BITS | BYTES | EXCEPTION | STRICT |
IOMMU | PAGER | PCIDEVICE | PMT | SUSPENDTOKEN | VCPU | SERVICE | FLEXIBLE |
CLOCK | RESOURCE_DEFINITION | ALIAS | TYPE | PROPERTIES