all meta languages

Post on 13-Sep-2014

557 Views

Category:

Education

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

 

TRANSCRIPT

Symbol Meaning

Predefined element

Fixed element

Path lines

� Allowable Paths – follow the railroad from left to right and follow only one path

� Eg, letter, sentence, program, variable name

Variable

� Reserved words,(Cannot use these words as variables (memory allocation) e.g., Dim, -+, 0, 1

Dim

As

� Eg, A Boolean Constant

T

F

� Eg, A word

Letter

� Eg, a number that can be either positive or negative

_

Digit

Were created to make it easier to represent syntax

Symbol Meaning :: = Is defined as

| Indicates choice between elements

< > Non terminal symbol

BNF is a text based metalanguage that is

read right to left. This way, syntax can be

represented by text, rather than diagrams

� Invented to avoid the disadvantages of

BNF.

� Easier to read, and less issues with things

like repetition and optional elements

Symbol Meaning = Is defined as

| Indicates choice between elements

< > Non terminal symbol

{ } Encloses elements to be repeated

[ ] Encloses optional elements

BNF EBNF

� ::=

� Boolean::=T|F

� =

� Boolean=T|F

BNF EBNF

� < >

� <Digit>::-0|1|2| � <Letter>::-a|b|c

� < >

� <Digit>=0|1|2| � <Letter>=a|b|c

BNF EBNF

� Written as is

� Dim � If � 0 � 1 � k

� Written as is

� Dim � If � 0 � 1 � k

BNF EBNF

� Defined as |

� Boolen::-T|F

� Defined as |

� Boolen=T|F

BNF EBNF

� No Optional Elements, so each option must be repeated

Integer::- - {<digit>} |{<digit>}

� [ ]

�  Integer=[-] {<digit>}

BNF EBNF

�  No repetition �  Repetition through

recursion �  Recursion is repetition

achieved through a process calling itself

�  Indicated by { } �  Word={Letter} �  Repeated zero or more

times �  If it needs to be repeated

one or more times, it is written as

�  Word=Letter{Letter}

Dim

Public

Private

Variable As Data Type

Boolean

Byte

Char

Date

Time

Decimal

Double

Int

Long

Short Single

Upper Case

LowerCase

UpperCase

Digit

1

2

3

4

5

6

7

8

9

0

� Construct an EBNF diagram to describe a best practice, legal if statement.

� Should follow the following structure: � If condition Then statements Else else

statements

top related