Pascal - EBNF and Railroad

 

Home

 

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)

letter { letter | digit }

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> ;

Machine generated alternative text:

 

 

Concatenation:

Text block = " <string> "

Final statement =  [<Text block> ]  [+ {<identifier> | <Text block>}]

 

String concatenation is "+".

Machine generated alternative text:

 

 

Message (print to screen) statements:

Text block = ' <string> '

Final statement = writeln( [<Text block> ]  [, {<identifier> | <Text block>]} );

 

Example from below

Machine generated alternative text:

 

String concatenation is "+".

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)

 

Machine generated alternative text:

 

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

N 人 X ^ C ↓ 0 日 0 Z 1 ) 「 
く P 「 い C95 代 
′ ・ つ 物 当 っ ー 物 ・ つ ・ J 
ノ つ テ つ ′ つ 
X 9 ョ ョ 0 つ 日 > 
4 ! 6 ℃

 

String:

Machine generated alternative text:

- ( string 
starters

 

 

Identifier:                                                    (Identifiers are Variable names)

Machine generated alternative text:

letter 
letter 
( digit

 

Declaration of variables:

Machine generated alternative text:
"lea

 

Machine generated alternative text:

Machine generated alternative text:

 

 

Concatenation - either:

Machine generated alternative text:

Or

Machine generated alternative text:

 

Machine generated alternative text:

(Note that data types must be the same)

 

Message (print to screen) statements:

Machine generated alternative text:

 

Machine generated alternative text:

 

Assignment

' top

Condition (evaluates to true or false):

 

(<identifier> ==|===|<|> <Text block> | <identifier> )

And you could have:

<condition> =(<condition> || <condition> AND <condition> )

( || means OR)

 

Machine generated alternative text:

 

 

Statement - block of code to be executed

Machine generated alternative text:
e ßlNT

 

 

 

 

"IF" statement: 

 

 

 

Machine generated alternative text:
else