blob: fc5ef13f3f30de0aa5acaa591f548e80165d0b4b [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|bits-or-enum-member")="fuchsia.developer.plugin.fidl.psi.FidlNamedElement"
extends(".*-declaration")="fuchsia.developer.plugin.fidl.psi.FidlNamedElementImpl"
extends("protocol-method|protocol-event|member-field|bits-or-enum-member")="fuchsia.developer.plugin.fidl.psi.FidlNamedElementImpl"
tokens = [
line_comment="regexp://.*"
]
}
file ::= library-header using-list? declaration-list
library-header ::= attribute-list? LIBRARY compound-identifier SEMICOLON
using-list ::= ( using SEMICOLON )*
using ::= USING_T compound-identifier ( AS identifier-token )?
declaration-list ::= ( declaration SEMICOLON )*
compound-identifier ::= identifier-token ( DOT identifier-token )*
declaration ::= bits-declaration |
const-declaration |
enum-declaration |
protocol-declaration |
struct-declaration |
table-declaration |
type-alias-declaration |
union-declaration |
service-declaration
declaration-modifiers ::= FLEXIBLE | STRICT
const-declaration ::= attribute-list? CONST type-constructor identifier-token EQUALS constant
enum-declaration ::= attribute-list? ( declaration-modifiers )*
ENUM identifier-token ( COLON type-constructor )?
OBRACE ( bits-or-enum-member SEMICOLON )+ CBRACE
bits-declaration ::= attribute-list? ( declaration-modifiers )*
BITS identifier-token ( COLON type-constructor )
OBRACE ( bits-or-enum-member SEMICOLON )+ CBRACE
bits-or-enum-member ::= attribute-list? identifier-token EQUALS bits-or-enum-member-value
bits-or-enum-member-value ::= identifier-token | literal
protocol-declaration ::= attribute-list? PROTOCOL identifier-token
OBRACE ( protocol-member SEMICOLON )* CBRACE
protocol-member ::= protocol-method | protocol-event | protocol-compose
protocol-method ::= attribute-list? identifier-token parameter-list ( ARROW parameter-list ( ERROR type-constructor )? )?
protocol-event ::= attribute-list? ARROW identifier-token parameter-list
parameter-list ::= OPAREN parameters? CPAREN
parameters ::= parameter ( COMMA parameter )*
parameter ::= attribute-list? type-constructor identifier-token
protocol-compose ::= COMPOSE compound-identifier
struct-declaration ::= attribute-list? STRUCT identifier-token OBRACE ( member-field SEMICOLON )* CBRACE
union-declaration ::= attribute-list? ( declaration-modifiers )* UNION identifier-token OBRACE ( ordinal-member-field SEMICOLON )+ CBRACE
table-declaration ::= attribute-list? ( declaration-modifiers )* TABLE identifier-token OBRACE ( ordinal-member-field SEMICOLON )* CBRACE
member-field ::= attribute-list? type-constructor identifier-token ( EQUALS constant )?
ordinal-member-field ::= attribute-list? ordinal COLON ordinal-member-field-body
ordinal-member-field-body ::= member-field | RESERVED
type-alias-declaration ::= attribute-list? USING_T identifier-token EQUALS type-constructor
service-declaration ::= attribute-list? SERVICE identifier-token OBRACE ( service-member SEMICOLON )* CBRACE
service-member ::= attribute-list? type-constructor identifier-token
attribute-list ::= doc-attribute-list | bracket-attribute-list
doc-attribute-list ::= ( DOC_COMMENT )+ bracket-attribute-list?
bracket-attribute-list ::= OBRACKET attributes CBRACKET
// Slightly different from master grammar for ease of parsing
attributes ::= attribute ( COMMA attribute )*
attribute ::= identifier-token ( EQUALS STRING_LITERAL )?
type-constructor ::= compound-identifier ( LANGLE type-constructor RANGLE )? type-constraint? ( QUESTION )?
| handle-type
handle-type ::= HANDLE ( LANGLE handle-subtype RANGLE )? ( QUESTION )?
handle-subtype ::= PROCESS | THREAD | VMO | CHANNEL | CLOCK | EVENT | PORT |
INTERRUPT | LOG | SOCKET | RESOURCE | EVENTPAIR |
JOB | VMAR | FIFO | GUEST | TIMER | EXCEPTION
type-constraint ::= COLON 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