BCL grammar
The Xtext grammar of BCL as shipped in this release.
The Xtext grammar the BIM Check Language parser is generated from, exactly as shipped in this release. Rules read top-down; => marks a syntactic predicate, += collects a list, ?= a boolean flag. Terminals not declared here (ID, STRING, INT, comments) come from the common Xtext terminals; the languages that build on BQL inherit every rule from it.
Text#
grammar nl.bimbase.bimworks.Bcl with nl.bimbase.bimworks.Bvl
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
generate bcl "http://www.bimbase.nl/bimworks/Bcl"
Bcl:
root=SelectBlock | programmed=ProgrammedCheck
;
Select:
"select" "(" booleanExpression=BooleanExpression ")" "{"
block=SelectBlock
"}"
("else" else=Select)?
(=>"else" "{" elseBlock=SelectBlock "}")?
;
Check:
"check" "(" booleanExpression=BooleanExpression ")" "{"
block=CheckBlock
"}"
("else" else=Check)?
(=>"else" "{" elseBlock=CheckBlock "}")?
;
SelectBlock:
{SelectBlock} (
("name" name=STRING)?
(actionSets+=ActionSet)*
(pick=PickBlock)?
(conditions+=IfCondition)*
(subSelects+=Select)*
// Optional branch with non-empty operands: if Checks/Requires could both match
// empty input, ANTLR always picked Checks and Requires was unreachable for
// empty blocks (warning(200) on EOF/'}').
(checks=Checks | requires=Requires)?
)
;
Requires:
{Requires} (requires += Require)+
;
Checks:
{Checks} (checks += Check)+
;
Require:
"require" (expression=BooleanExpression) ";"
;
CheckBlock:
{CheckBlock}
(actionSets+=ActionSet)*
(pick=PickBlock)?
result = Result
";"
;
// What a click on a result object shows (docs/check-result-interaction-design.md §5.1): action sets
// applied to the picked object while it is picked - colours, ON_TOP, annotations, figures such as
// OUTLINE or PATH. A select block's pick applies to every result of the select, a check block's to
// the results of that branch (after the select's). The optional text is the hint the viewer shows
// on hover ("Click a space to show its escape route").
// pick "Click a space to show its escape route" { COLOR RESULT 20%; SHOW PATH($exits, FROM CENTROID, LIFT 1000 mm); }
PickBlock:
{PickBlock}
"pick" (hint=STRING)? "{"
(actionSets+=ActionSet)*
"}"
;
Result:
Success | Error | Warning | Info
;
Success returns Result:
{Success}
"success" ("(" (keyword=ID ",")? message=LabelValue ")")?
;
Error returns Result:
{Error}
"error" ("(" (keyword=ID ",")? message=LabelValue ")")?
;
Warning returns Result:
{Warning}
"warning" ("(" (keyword=ID ",")? message=LabelValue ")")?
;
Info returns Result:
{Info}
"info" ("(" (keyword=ID ",")? message=LabelValue ")")?
;
ProgrammedCheck:
{ProgrammedCheck}
"class" name = ID
config = XJsonObject
;
XJsonValue:
XJsonObject | XJsonArray | XJsonNumber | XJsonString | XJsonBoolean | XJsonNull ;
XJsonObject:
{XJsonObject} '{' (pairs+=XJsonPair (',' pairs+=XJsonPair)*)? '}' ;
XJsonPair:
string=STRING ":" value=XJsonValue;
XJsonArray:
{XJsonArray} '[' (values+=XJsonValue (',' values+=XJsonValue)*)? ']' ;
XJsonNumber:
XJsonLong | XJsonDouble
;
XJsonLong:
{XJsonLong}
value=LONG
;
XJsonDouble:
{XJsonDouble}
value=DOUBLE
;
XJsonString:
{XJsonString} value=STRING ;
XJsonBoolean:
{XJsonTrue} 'true' | {XJsonFalse} 'false' ;
XJsonNull:
{XJsonNull} 'null' ;