Skip to content

Kendrick grammar in EBNF

Serge Stinckwich edited this page Dec 12, 2019 · 5 revisions
<KENDRICK-SCRIPT> ::= <KENDRICK-ENTITIES>+

<KENDRICK-ENTITIES> ::= <MODEL-DECLARATION>
	| <CONCERN-DECLARATION>
	| <COMPOSITION-DECLARATION>
	| <SIMULATION-DECLARATION>
	| <VISUALIZATION-DECLARATION>

<IDENTIFIER> ::= <LETTER> (<LETTER> | [0-9]+)*

<COMPOSITE-IDENTIFIER> ::= <IDENTIFIER> ("_" <IDENTIFIER>)+

<LETTER> ::= [a-zA-Z]

<NUMBER> ::= [0-9]+ ("."[0-9]+)?

<STRING> ::= "'" [\^~']* "'"

<KEYWORD> ::= <IDENTIFIER> ":"

<VALUE> ::= <NUMBER> | <STRING> | <ARRAY>

<SHORT-EQ-WITH-OP> ::= <EQUATION-EXPRESSION> <BASIC-OP>*

<BASIC-OP> ::= "sum"|"sqrt"|"size"|"min"|"max"|"avg"|"median"|"mean"

<ARRAY> ::=  "#(" (<VALUE>* | <SHORT-EQ-WITH-OP>) ")"

<COMMON-EXPRESSION> ::= <ATTRIBUTE-DEFINITION>
	| <PARAMETERS-DEFINITION>
	| <ASSIGNMENT-CLAUSE>
	| <EQUATIONS-DEFINITION>
	| <TRANSITIONS-DEFINITION>

<ATTRIBUTE-DEFINITIONS> ::= "attribute:" <ATTRIBUTE-ARRAY>

<ATTRIBUTE-ARRAY> ::= "#(" <IDENTIFIER> "->" (<IDENTIFIER> | <NUMBER>)+ ")"

<ASSIGNMENT-CLAUSE> ::= <KEYWORD> <VALUE>

<PARAMETER-DEFINITIONS> ::= "parameters:" <IDENTIFIER-ARRAY>

<IDENTIFIER-ARRAY> ::= "#(" <IDENTIFIER>+ ")"

<EQUATIONS-CLAUSE> ::= "equations:" <EQUATIONS-ARRAY>

<EQUATIONS-ARRAY> ::= "#(" (<EQUATION> ".")+ ")"

<EQUATION> ::=  <EQUATION-SIGNATURE> "=" <EQUATION-EXPRESSION>

<EQUATION-SIGNATURE> ::= <IDENTIFIER> ":" <IDENTIFIER>

<EQUATION-EXPRESSION> ::= <TERM> (("+"|"-") <EQUATION-EXPRESSION>)*

<TERM> ::= <NUMBER>|<IDENTIFIER>|<COMPOSITE-IDENTIFIER>|"("EQUATION-EXPRESSION")"|<PRODUCT>

<PRODUCT> ::= <TERM> "*" <TERM>

<TRANSITIONS-DEFINITION> ::= "transitions:" <TRANSITIONS-ARRAY>

<TRANSITIONS-ARRAY> ::= "#(" <TRANSITION>+ ")"

<TRANSITION> ::= <IDENTIFIER> "--" <IDENTIFIER> "-->" <IDENTIFIER>

<MODEL-DECLARATION> ::= "KendrickModel" <IDENTIFIER> <MODEL-BODY>

<MODEL-BODY> ::= (<MODEL-EXPRESSION> ";") * <MODEL-EXPRESSION> "."

<MODEL-EXPRESSION> ::= <POPULATION-CLAUSE> | <COMMON-EXPRESSION>

<POPULATION-CLAUSE> ::= "populationSize:" <NUMBER>

<CONCERN-DECLARATION> ::= "Concern" <IDENTIFIER> <CONCERN-BODY>

<CONCERN-BODY> ::= (<CONCERN-EXPRESSION> ";") * <CONCERN-EXPRESSION> "."

<CONCERN-EXPRESSION> ::= <EXTENTION-CLAUSE>
	| <OPERATOR-CLAUSE>
	| <COMMON-EXPRESSION>

<EXTENTION-CLAUSE> ::= "extends:" <IDENTIFIER>

<OPERATOR-CLAUSE> ::= <DELAY-CLAUSE>
	| <DIVIDE-CLAUSE>
	| <ADD-CLAUSE>
	| <TRANSITION-CLAUSE>

<DELAY-CLAUSE> ::= "delay:" "#(" <IDENTIFIER> "," <TRANSITION> "," <IDENTIFIER> ")"

<DIVIDE-CLAUSE> ::= "divide:" "#(" <IDENTIFIER>, "," <IDENTIFIER> "," <IDENTIFIER> ")"

<ADD-CLAUSE> ::= "addStatus:" "#(" <IDENTIFIER> "+" <IDENTIFIER> ")"

<LINK-CLAUSE> ::= "addTransition:" "#(" <TRANSITION> ")"

<COMPOSITION-DECLARATION> ::= "Composition" <IDENTIFIER> <COMPOSITION-BODY>

<COMPOSITION-BODY> ::= (<COMPOSITION-EXPRESSION> ";") * <COMPOSITION-EXPRESSION> "."

<COMPOSITION-EXPRESSION> ::= <MODEL-CLAUSE>
	| <POPULATION-CLAUSE>
	| <CONCERN-CLAUSE>
	| <COMPOSITE-ASSIGNMENT>
	| <COMMON-EXPRESSION>

<MODEL-CLAUSE> ::= "model:" <STRING>

<CONCERN-CLAUSE> ::= "concern:" <STRING>

<COMPOSITE-ASSIGNMENT-CLAUSE> ::= <COMPOSITE-IDENTIFIER> ":" <VALUE>

<SIMULATION-DECLARATION> ::= "Simulation" <IDENTIFIER> <SIMULATION-MODIFIER> <SIMULATION-BODY>

<SIMULATION-MODIFIER> ::= "RungeKutta" | "AB2" | "AM3" | "BDF4" | "Euler" | "Heun" | "ImplicitMidPoint" | "AB4" | "BeckwardEuler" | "BDF3" | "Midpoint" | "Trapezoid" | "AB3" | "BDF2" | "AM4" | "Gillespie" | "GPUGillespie" | "TauLeap" | "IBM"

<SIMULATION-BODY> ::= (<SIMULATION-EXPRESSION> ";") * <SIMULATION-EXPRESSION> "."

<SIMULATION-EXPRESSION> ::= (("from:" | "to:" | "step:") <NUMBER>) | "for:" <IDENTIFIER>

<VISUALIZATION-DECLARATION> ::= "Visualization"  <IDENTIFIER> <VISUALIAZATION-MODIFIER> <VISUALIZATION-BODY>

<VISUALIZATION-MODIFIER> ::= "diagram" | "pieChart" | "barPlot" | "map"

<VISUALIZATION-BODY> ::= (<VISUALIZATION-EXPRESSION> ";") * <VISUALIZATION-EXPRESSION> "."

<VISUALIZATION-EXPRESSION> ::= "for:" <IDENTIFIER>
	| ("xlabel:" | "ylabel:" | "legendTitle:") <STRING>
	| "data:" <SHORT-EQ-WITH-OP>
	| "legends:" <ARRAY>

Custom sidebar of the Kendrick Wiki

Basic-SIR

SIR---Metapopulation

Clone this wiki locally