Pascal - EBNF and Railroad
Functions defined:
EBNF
Pascal - definitions:
sign
"+" | "-"
letter
"A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"
digit
"0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
special character (including "space")
" " | "*" | "/" | "=" | "<" | ">" | "[" | "]" | "." | "," | "(" | ")" | ":" | "^" | "@" | "{" | "}" | "$" | "#" | "&" | "%"
string-character
any character or digit except quote | "''"
string
<string-character> { <special character> | <string-character> }
identifier (Identifiers are Variable names)
From <http://www.fit.vutbr.cz/study/courses/APR/public/ebnf.html>
Declaration of variables:
<a>declaration</a>
dataType = Integer|SmallInt| LongInt | Real| Single| Currency| Boolean | Char | String
DimStatement = var <identifier> { , <identifier>} : <DataType> ;
Concatenation:
Text block = " <string> "
Final statement = [<Text block> ] [+ {<identifier> | <Text block>}]
Message (print to screen) statements:
Text block = ' <string> '
Final statement = writeln( [<Text block> ] [, {<identifier> | <Text block>]} );
Final statement = ( [<Text block> ] [+ {<Text block>}] );
Assignment:
<identifier> := <Text block> | <identifier> {<Text block> | <identifier>}] ;
Condition (evaluates to true or false):
(<identifier> ==|===|<|> <Text block> | <identifier> )
And you could have:
<condition> =(<condition> || <condition> AND <condition> )
( || means OR)
Statement - block of code to be executed
[ label ":" ] (simple-statement | structured-statement)
simple-statement
[ assignment-statement | procedure-statement | goto-statement ]
structured-statement
compound-statement | repetitive-statement | conditional-statement | with-statement
From <http://www.fit.vutbr.cz/study/courses/APR/public/ebnf.html>
From <http://www.fit.vutbr.cz/study/courses/APR/public/ebnf.html>
From <http://www.fit.vutbr.cz/study/courses/APR/public/ebnf.html>
"IF" statement:
Railroad:
Definitions
String:
Identifier: (Identifiers are Variable names)
Declaration of variables:
Concatenation - either:
Or
(Note that data types must be the same)
Message (print to screen) statements:
Assignment
Condition (evaluates to true or false):
(<identifier> ==|===|<|> <Text block> | <identifier> )
And you could have:
<condition> =(<condition> || <condition> AND <condition> )
( || means OR)
Statement - block of code to be executed
"IF" statement: