meta languages railroad diagrams

Post on 16-Apr-2017

2.307 Views

Category:

Education

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Kelly Bauer

META LANGUAGES

WHY? Describes the syntax of a computer

language

Rules that govern the arrangement of elements in a language

eg. The ran catORThe cat ran

WHY NOT JUST LEARN THE LANGUAGE?

Programming languages are very complex. You cant possibly know every way to do everything that you want.

The likelihood is that you won’t program in the language you learn.

WHY NOT JUST LEARN THE LANGUAGE?

Programming languages are very complex. You cant possibly know every way to do everything that you want.

The likelihood is that you won’t program in the language you learn.

Allows language specifications be understood by programmers and allows more learnability between languages

2 BASIC FORMS Railroad diagram (aka syntax structure

diagrams) BNF/EBNF

RAILROAD DIAGRAMS

ELEMENTS Allowable Paths

PRE DEFINED LANGAUGE ELEMENTS

Eg, letter, sentence, program, variable name

Variable

FIXED ELEMENTS Reserved words, eg, Dim, -+, 0, 1

Dim

As

THE ELEMENTS CAN BE COMBINED TO GIVE OPTIONS

Eg, A Boolean Constant

T

F

OR TO REPEAT ELEMENTS Eg, A word

Letter

AND THESE CAN THEN BE COMBINED Eg, a number that can be either

positive or negative

_

Digit

TEXTBOOK Pg 168 Defines the Winston language

in railroad diagrams Is the following legitimate conditions

Abcd = +99

ABCD = +99 Abcd is a legitimate identifier, because

it starts with an uppercase followed by a number of lower case

+99 is a legitimate constant because it is a negative followed by a number of digits

The statement follows the correct order of

Identifier condition constantDavis, Sam (2008) Software Design and Development: The Preliminary Course, Parramatta Education Centre, Sydney

ABCD = +99 Abcd is a legitimate identifier, because

it starts with an uppercase followed by a number of lower case

+99 is a legitimate constant because it is a negative followed by a number of digits

The statement follows the correct order of

Identifier condition constant

Complete 2nd activity on pg 168

TEXT ACTIVITY

AN EXAMPLE

IN VISUAL BASIC Construct a railroad diagram to

describe a best practice, legal variable declaration.

Should follow the following structure: Dim Public or Private Variable Name As

Data Type

Dim

Public

Private

Variable As Data Type

From this, what needs to be further defined?

DATA TYPE In Visual Basic, this can be Boolean,

Byte, Char, Date, Time, Decimal, Double, Int, Long, Object, Short, Single

Boolean

ByteChar

Date

Time

DecimalDouble

IntLong

ShortSingle

VARIABLES IN VB Must begin with an uppercase letter Can be lower or upper case or digits

after first letter

Upper Case

LowerCase

UpperCase

Digit

1

2

3

4

5

6

7

8

9

0

top related