.

Построение формального языка L

Язык: русский
Формат: реферат
Тип документа: Word Doc
0 984
Скачать документ

Iino?iaiea oi?iaeueiiai ycuea L

WHILE( ) [, , …])>];

WHILE – aoiaeiie oa?ieiaeueiue neiaie

– oneiaiia au?aaeaiea

– iaeioi?ay ooieoeey, eioi?ay iiaeao ionoonoaiaaoue

– ia?aiao?u ooieoeee, eioi?ua oiaea iiaoo ionoonoaiaaoue

I?eia? i?aaeeueiiai neioaenena:

WHILE(A>4444]:

( while( ) [];

( T| < T| > T| <= T | >= T | != T

( O | T*O | T**O | T+O | T-O | T/O

( () | |

( A{A|Oe}

( Oe{Oe}

( ([{,}])

( | | (

Eeanneoeeaoeey G[Z]

G[]:

( while( ) [];

( T| < T| > T| <= T | >= T | != T

( O | T*O | T**O | T+O | T-O | T/O

( () | |

( A{A|Oe}

( Oe{Oe}

( ([{,}])

( | | (

Naeaeaai caiaio iaoa?ieiaeueiuo neiaieia:

( Z

( A

( B

( C

( D

( E

( F

( G

Naeaeaai caiaio oa?ieiaeueiuo neiaieia:

WHILE ( a

( ( b

) ( c

; ( d

Oe ( f

A ( g

, ( h

G[Z]:

Z ( abAc[D]d

A( B|A B|A <= B |A >= B |A != B

B ( C | B*C | B**C | B+C | B-C | B/C

C ( bAc | E | F

E ( g{g|f}

F ( f{f}

D ( Eb[G{hG}]c

G ( E | F | (

Auaiae : G[Z] – eiioaenoii-naiaiaeiay a?aiiaoeea.

Auai? iaoiaea aiaeeca

Oioy iaeiicia/iinoue a iauai neo/aa aeey eiioaenoii-caaeneiuo a?aiiaoee
ia aeieacaia, aa eniieueciaaiea aiciiaeii aeey a?aiiaoee a eioi?uo
iaeiicia/iinoue i/aaeaeia. Iaeaieaa oi?ioi ?ac?aaioaiiui iaoiaeii
aiaeeca, aeey aeaiiiai oeia a?aiiaoee yaeyaony, iaoiae ?aeo?neaiiai
nionea.

Aeeaaiinoeea e iaeo?aeecaoeey ioeaie

?ac?aaioaiiue aeai?eoi ioiineony e iauaecaanoiiio iaoiaeo
neioaene/aneiai ?acai?a, i?aaeeiaeaiiue Ae?iinii.

Iniiaiay eaeay iaoiaea ninoieo a oii, /oi ii eiioaenoo aac aica?aoa
ioa?anuaathony oa neiaieu, eioi?ua i?eaaee a ooieeiaoth neooaoeeth e
?acai? i?iaeieaeaaony.

I?eaaaeai i?eia? neioaene/aneiai ?acai?a:

While (A > ) cls();

Z ( abAc[D]d

A( B|A B|A <= B |A >= B |A != B

B ( C | B*C | B**C | B+C | B-C | B/C

C ( bAc | E | F

E ( g{g|f}

F ( f{f}

D ( Eb[G{hG}]c

G ( E | F | (

Z

a b A c D

B A E

C B g{g} b G c

E C (

g E

g

While ( A > ) cls ( )
;

ooieeiaay neooaoeey

Oanoe?iaaiea ia oeaii/eao

I?ioieie ?aaiou neioaene/aneiai ?aniiciaaaoaey iia?aoi?a oeeeea while
ycuea N.

_____________________________________________________________________

Ia?aaaouaaai no?i/eo – While(a>)cls();

Iaeaeai While i?iaa?ea ia/aeanue n neiaiea – (

I?iaa?ea ia AB

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia IDENT, oaeouee neiaie – a

I?iaa?ea ia AB

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia IDENT, oaeouee neiaie – )

I?iaa?ea ia OeAC, oaeouee neiaie – )

I?iaa?ea ia FUNC, oaeouee neiaie – c

I?iaa?ea ia IDENT, oaeouee neiaie – c

Iaeaeaiiua ioeaee a no?iea While(a>)cls();

I?aaeoi?aaeaeaiea: Ionoonoaoao oneiaea ()

Ia iaeaeai eaeaioeoeeaoi? eee OeAC

_____________________________________________________________________

Ia?aaaouaaai no?i/eo – while(1<(3*(43+5*(3-4-(4<454)))) ;Iaeaeai While i?iaa?ea ia/aeanue n neiaiea - (I?iaa?ea ia ABI?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia IDENT, oaeouee neiaie - 1I?iaa?ea ia OeAC, oaeouee neiaie - 1I?iaa?ea ia ABI?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia ABI?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia IDENT, oaeouee neiaie - 3I?iaa?ea ia OeAC, oaeouee neiaie - 3I?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia ABI?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia IDENT, oaeouee neiaie - 4I?iaa?ea ia OeAC, oaeouee neiaie - 4I?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia IDENT, oaeouee neiaie - 5I?iaa?ea ia OeAC, oaeouee neiaie - 5I?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia ABI?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia IDENT, oaeouee neiaie - 3I?iaa?ea ia OeAC, oaeouee neiaie - 3I?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia IDENT, oaeouee neiaie - 4I?iaa?ea ia OeAC, oaeouee neiaie - 4I?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia ABI?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia IDENT, oaeouee neiaie - 4I?iaa?ea ia OeAC, oaeouee neiaie - 4I?iaa?ea ia ABI?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia IDENT, oaeouee neiaie - 4I?iaa?ea ia OeAC, oaeouee neiaie - 4I?iaa?ea ia FUNC, oaeouee neiaie - ;I?iaa?ea ia IDENT, oaeouee neiaie - ;Iaeaeaiiua ioeaee a no?iea while(1<(3*(43+5*(3-4-(4<454)))) ;Ionoonoaoao )I?aaeoi?aaeaeaiea: ionoonoaoao eiy ooieoeee_____________________________________________________________________Ia?aaaouaaai no?i/eo - 435 4 whilei>>3t*(ewqw++()*we)
rscr(456,345,rtgrt,345444rtr,,,)

Iaeaeai While i?iaa?ea ia/aeanue n neiaiea – i

I?iaa?ea ia AB

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia IDENT, oaeouee neiaie – i

I?iaa?ea ia AB

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia IDENT, oaeouee neiaie – 3

I?iaa?ea ia OeAC, oaeouee neiaie – 3

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia AB

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia IDENT, oaeouee neiaie – e

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia IDENT, oaeouee neiaie – +

I?iaa?ea ia OeAC, oaeouee neiaie – +

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia IDENT, oaeouee neiaie – w

I?iaa?ea ia FUNC, oaeouee neiaie – r

I?iaa?ea ia IDENT, oaeouee neiaie – r

I?iaa?ea ia PAR, oaeouee neiaie – 4

I?iaa?ea ia IDENT, oaeouee neiaie – 4

I?iaa?ea ia OeAC, oaeouee neiaie – 4

I?iaa?ea ia PAR, oaeouee neiaie – 3

I?iaa?ea ia IDENT, oaeouee neiaie – 3

I?iaa?ea ia OeAC, oaeouee neiaie – 3

I?iaa?ea ia PAR, oaeouee neiaie – r

I?iaa?ea ia IDENT, oaeouee neiaie – r

I?iaa?ea ia PAR, oaeouee neiaie – 3

I?iaa?ea ia IDENT, oaeouee neiaie – 3

I?iaa?ea ia OeAC, oaeouee neiaie – 3

I?iaa?ea ia PAR, oaeouee neiaie – ,

I?iaa?ea ia IDENT, oaeouee neiaie – ,

I?iaa?ea ia OeAC, oaeouee neiaie – ,

Iaeaeaiiua ioeaee a no?iea 435 4 whilei>>3t*(ewqw++()*we)
rscr(456,345,rtgrt,345444rtr,,,)

Ionoonoaoao (

Ionoonoaoao )

I?aaeoi?aaeaeaiea: Ionoonoaoao oneiaea ()

Ionoonoaoao ; iinea ooieoeee

Ia?aiao? ooieoeee ia iiaeao ia/eiaony n oeeo?u

Iaecaanoiue eaeaioeoeeaoi?(u) –

435, 4,

Ia iaeaeai eaeaioeoeeaoi? eee OeAC

Eaeaioeoeeaoi? ia iiaeao ia/eiaoueny n oeeo?u

Ia iaeaeai eee ia aa?iue ia?aiao?

Iaecaanoiay ciaeiaay eiino?oeoeey

_____________________________________________________________________

Ia?aaaouaaai no?i/eo – whiLE(43-(sss<233)fewfew) sd(we)Iaeaeai While i?iaa?ea ia/aeanue n neiaiea - (I?iaa?ea ia ABI?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia IDENT, oaeouee neiaie - 4I?iaa?ea ia OeAC, oaeouee neiaie - 4I?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia ABI?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia IDENT, oaeouee neiaie - sI?iaa?ea ia ABI?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia IDENT, oaeouee neiaie - 2I?iaa?ea ia OeAC, oaeouee neiaie - 2I?iaa?ea ia ABI?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia IDENT, oaeouee neiaie - fI?iaa?ea ia FUNC, oaeouee neiaie -I?iaa?ea ia IDENT, oaeouee neiaie - sI?iaa?ea ia PAR, oaeouee neiaie - wI?iaa?ea ia IDENT, oaeouee neiaie - wIaeaeaiiua ioeaee a no?iea whiLE(43-(sss<233)fewfew) sd(we)Ionoonoaoao ; iinea ooieoeeeI?iiouaii / eee * eee ** eee + eee -_____________________________________________________________________Ia?aaaouaaai no?i/eo - while(i>344>(5445<<2323*343243+2343*(w))>23*232)
clrscr(,)

Iaeaeai While i?iaa?ea ia/aeanue n neiaiea – (

I?iaa?ea ia AB

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia IDENT, oaeouee neiaie – i

I?iaa?ea ia AB

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia IDENT, oaeouee neiaie – 3

I?iaa?ea ia OeAC, oaeouee neiaie – 3

I?iaa?ea ia AB

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia AB

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia IDENT, oaeouee neiaie – 5

I?iaa?ea ia OeAC, oaeouee neiaie – 5

I?iaa?ea ia AB

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia IDENT, oaeouee neiaie – 2

I?iaa?ea ia OeAC, oaeouee neiaie – 2

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia IDENT, oaeouee neiaie – 3

I?iaa?ea ia OeAC, oaeouee neiaie – 3

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia IDENT, oaeouee neiaie – 2

I?iaa?ea ia OeAC, oaeouee neiaie – 2

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia AB

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia IDENT, oaeouee neiaie – w

I?iaa?ea ia AB

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia IDENT, oaeouee neiaie – 2

I?iaa?ea ia OeAC, oaeouee neiaie – 2

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia IDENT, oaeouee neiaie – 2

I?iaa?ea ia OeAC, oaeouee neiaie – 2

I?iaa?ea ia FUNC, oaeouee neiaie –

I?iaa?ea ia IDENT, oaeouee neiaie – c

I?iaa?ea ia PAR, oaeouee neiaie – ,

I?iaa?ea ia IDENT, oaeouee neiaie – ,

I?iaa?ea ia OeAC, oaeouee neiaie – ,

Iaeaeaiiua ioeaee a no?iea
while(i>344>(5445<<2323*343243+2343*(w))>23*232) clrscr(,)

Ionoonoaoao ; iinea ooieoeee

Ia iaeaeai eee ia aa?iue ia?aiao?

Iaecaanoiay ciaeiaay eiino?oeoeey

_____________________________________________________________________

Ia?aaaouaaai no?i/eo – while(u>r+erhgeerg(e>=rwe+++r+788erwe++))
scr(eee,qee<)Iaeaeai While i?iaa?ea ia/aeanue n neiaiea - (I?iaa?ea ia ABI?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia IDENT, oaeouee neiaie - uI?iaa?ea ia ABI?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia IDENT, oaeouee neiaie - rI?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia IDENT, oaeouee neiaie - eI?iaa?ea ia ABI?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia ABI?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia IDENT, oaeouee neiaie - eI?iaa?ea ia ABI?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia IDENT, oaeouee neiaie - rI?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia IDENT, oaeouee neiaie - rI?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia IDENT, oaeouee neiaie - 7I?iaa?ea ia OeAC, oaeouee neiaie - 7I?iaa?ea ia FUNC, oaeouee neiaie -I?iaa?ea ia IDENT, oaeouee neiaie - sI?iaa?ea ia PAR, oaeouee neiaie - eI?iaa?ea ia IDENT, oaeouee neiaie - eI?iaa?ea ia PAR, oaeouee neiaie - qI?iaa?ea ia IDENT, oaeouee neiaie - qI?iaa?ea ia PAR, oaeouee neiaie - r+erhgeerg(e>=rwe+++r+788erwe++))
scr(eee,qee<)Ionoonoaoao ; iinea ooieoeeeI?iiouaii / eee * eee ** eee + eee -Eaeaioeoeeaoi? ia iiaeao ia/eiaoueny n oeeo?uIa iaeaeai eee ia aa?iue ia?aiao?_____________________________________________________________________Ia?aaaouaaai no?i/eo - while(i>77777u777) clrscr(,…,)

Iaeaeai While i?iaa?ea ia/aeanue n neiaiea – (

I?iaa?ea ia AB

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia IDENT, oaeouee neiaie – i

I?iaa?ea ia AB

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia IDENT, oaeouee neiaie – 7

I?iaa?ea ia OeAC, oaeouee neiaie – 7

I?iaa?ea ia FUNC, oaeouee neiaie –

I?iaa?ea ia IDENT, oaeouee neiaie – c

I?iaa?ea ia PAR, oaeouee neiaie – ,

I?iaa?ea ia IDENT, oaeouee neiaie – ,

I?iaa?ea ia OeAC, oaeouee neiaie – ,

Iaeaeaiiua ioeaee a no?iea while(i>77777u777) clrscr(,…,)

Ionoonoaoao ; iinea ooieoeee

Eaeaioeoeeaoi? ia iiaeao ia/eiaoueny n oeeo?u

Ia iaeaeai eee ia aa?iue ia?aiao?

_____________________________________________________________________Ia?
aaaouaaai no?i/eo – while(4545>>445— ;

Iaeaeai While i?iaa?ea ia/aeanue n neiaiea – (

I?iaa?ea ia AB

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia IDENT, oaeouee neiaie – 4

I?iaa?ea ia OeAC, oaeouee neiaie – 4

I?iaa?ea ia AB

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia IDENT, oaeouee neiaie – 4

I?iaa?ea ia OeAC, oaeouee neiaie – 4

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia IDENT, oaeouee neiaie –

I?iaa?ea ia OeAC, oaeouee neiaie –

I?iaa?ea ia FUNC, oaeouee neiaie – ;

I?iaa?ea ia IDENT, oaeouee neiaie – ;

Iaeaeaiiua ioeaee a no?iea while(4545>>445— ;

Ionoonoaoao )

I?aaeoi?aaeaeaiea: ionoonoaoao eiy ooieoeee

Ia iaeaeai eaeaioeoeeaoi? eee OeAC

Iaecaanoiay ciaeiaay eiino?oeoeey

_____________________________________________________________________

Ia?aaaouaaai no?i/eo – while(i>=0);

Iaeaeai While i?iaa?ea ia/aeanue n neiaiea – (

I?iaa?ea ia AB

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia IDENT, oaeouee neiaie – i

I?iaa?ea ia AB

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia IDENT, oaeouee neiaie – 0

I?iaa?ea ia OeAC, oaeouee neiaie – 0

I?iaa?ea ia FUNC, oaeouee neiaie – ;

I?iaa?ea ia IDENT, oaeouee neiaie – ;

Iaeaeaiiua ioeaee a no?iea while(i>=0);

I?aaeoi?aaeaeaiea: ionoonoaoao eiy ooieoeee

_____________________________________________________________________

Ia?aaaouaaai no?i/eo – while(i>=0) 544();

Iaeaeai While i?iaa?ea ia/aeanue n neiaiea – (

I?iaa?ea ia AB

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia IDENT, oaeouee neiaie – i

I?iaa?ea ia AB

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia IDENT, oaeouee neiaie – 0

I?iaa?ea ia OeAC, oaeouee neiaie – 0

I?iaa?ea ia FUNC, oaeouee neiaie –

I?iaa?ea ia IDENT, oaeouee neiaie – 5

Iaeaeaiiua ioeaee a no?iea while(i>=0) 544();

Ionoonoaoao ; iinea ooieoeee

I?aaeoi?aaeaeaiea: ionoonoaoao eiy ooieoeee

_____________________________________________________________________

Ia?aaaouaaai no?i/eo – whilei>=0) clrscr();13

Iaeaeai While i?iaa?ea ia/aeanue n neiaiea – i

I?iaa?ea ia AB

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia IDENT, oaeouee neiaie – i

I?iaa?ea ia AB

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia IDENT, oaeouee neiaie – 0

I?iaa?ea ia OeAC, oaeouee neiaie – 0

I?iaa?ea ia FUNC, oaeouee neiaie –

I?iaa?ea ia IDENT, oaeouee neiaie – c

Iaeaeaiiua ioeaee a no?iea whilei>=0) clrscr();13

Ionoonoaoao (

I?aaeoi?aaeaeaiea: Ionoonoaoao oneiaea ()

_____________________________________________________________________

Ia?aaaouaaai no?i/eo – whilertt<=243+++344-23!=345 wwqwq;Iaeaeai While i?iaa?ea ia/aeanue n neiaiea - rI?iaa?ea ia ABI?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia IDENT, oaeouee neiaie - rI?iaa?ea ia ABI?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia IDENT, oaeouee neiaie - 2I?iaa?ea ia OeAC, oaeouee neiaie - 2I?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia IDENT, oaeouee neiaie - 3I?iaa?ea ia OeAC, oaeouee neiaie - 3I?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia IDENT, oaeouee neiaie - 2I?iaa?ea ia OeAC, oaeouee neiaie - 2I?iaa?ea ia ABI?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia IDENT, oaeouee neiaie - =I?iaa?ea ia OeAC, oaeouee neiaie - =I?iaa?ea ia ABI?iaa?ea ia TERMI?iaa?ea ia OI?iaa?ea ia IDENT, oaeouee neiaie - 3I?iaa?ea ia OeAC, oaeouee neiaie - 3I?iaa?ea ia FUNC, oaeouee neiaie - wI?iaa?ea ia IDENT, oaeouee neiaie - wIaeaeaiiua ioeaee a no?iea whilertt<=243+++344-23!=345 wwqwq;Ionoonoaoao (Ionoonoaoao )Ia iaeaeai eaeaioeoeeaoi? eee OeACIa iaeaeai eee ia aa?iue ia?aiao?_____________________________________________________________________Ia?aaaouaaai no?i/eo - while(dd>>3432*23432)

Iaeaeai While i?iaa?ea ia/aeanue n neiaiea – (

I?iaa?ea ia AB

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia IDENT, oaeouee neiaie – d

I?iaa?ea ia AB

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia IDENT, oaeouee neiaie – 3

I?iaa?ea ia OeAC, oaeouee neiaie – 3

I?iaa?ea ia TERM

I?iaa?ea ia O

I?iaa?ea ia IDENT, oaeouee neiaie – 2

I?iaa?ea ia OeAC, oaeouee neiaie – 2

I?iaa?ea ia FUNC, oaeouee neiaie –

I?iaa?ea ia IDENT, oaeouee neiaie –

Iaeaeaiiua ioeaee a no?iea while(dd>>3432*23432)

Ionoonoaoao ; iinea ooieoeee

I?aaeoi?aaeaeaiea: ionoonoaoao eiy ooieoeee

Iaecaanoiay ciaeiaay eiino?oeoeey

Eenoeia i?ia?aiiu

AA?EAHO # 10

Neioaene/aneee ?aniiciiaaoaeue iia?aoi?a oeeeea While

Oaee i?ia?aiiu – A513.cpp

n oaenoii aeey ?aniiciiaaiey – test.513

n i?ioieieii ?aaiou – error.513

Eaoaaepa : ANO

Apoiia : A-513

Nooaeaio : Noa?eeia Aeieo?ee Aeaenaiae?iae/

Ipaiiaeaaaoaee : eaiaeeaeao oaoie/aneeo iaoe, aeioeaio

Oipieeia THpee Aeaaeeiepiae/,

annenoaio Iaiiaa Aapa Aipeniaia

Aeaoa : 30 iay 1997a.

//———————————————————————-
——

// Caaieiai/iua oaeeu.

//———————————————————————-
——

#include

#include

#include

#include

#include

#include

#define UP 72 // no?aeea aaa?o

#define DOWN 80 // no?aeea aiec

#define ALTX 45 // auoiae

#define F1 59

#define F2 60

#define F3 61

#define ESC 27

#define FL_NAME “test.513”

#define FL_TEST “error.513”

void open_fl(void); // ioepuoue oaee

void work_space(void); // oipaaeyao paai/ae iaeanoueth

void print_page(void); // ia/aoaao oaeno ia yepai

void help_line(void); // oaeno n iiiiuueth ieaeiyy nopi/ea

void help(int);

int scan(); // Aeaeaao ?acai? no?iee

int my_while(); // iiapaoip

int AB(); // a?eoiaoe/aneia au?aaeaiea

int TERM(); // Oa?i

int O(); // Iia?aiae

int IDENT(); // Eaeaioeoeeaoi?

int ZBZ(); // Oeaeia aac ciaea

int FUNC(); // Ooieoeey

int PAR(); // Ia?aiao?

char TEXT[22][80];

int position; // Iiia? oaeouae no?aieoeu

int cur_y=3; // iieiaeaiea eopnipa ia yepaia

int x,y; // Oaeouay iiceoeey i?e eiiieeyoeee a
no?i/ea

int f=0; // I?e f=1 ioeaee aeey ooieoeee

char screen[4096]; // Niopaiyao iieioth eiieth yepaia

char screen1[4096]; // Niopaiyao /anoue yepaia

char *mistake[]={“Ioeaie iao!!!”, //0

“Iiapaoip while ia iaeaeai”, //1

“Ionoonoaoao (“, //2

“Ionoonoaoao )”, //3

“I?aaeoi?aaeaeaiea: Ionoonoaoao oneiaea ()”, //4

“Ionoonoaoao ; iinea ooieoeee”, //5

“I?aaeoi?aaeaeaiea: ionoonoaoao eiy ooieoeee”, //6

“I?iiouaii / eee * eee ** eee + eee – “, //7

“”, //8

“Ia?aiao? ooieoeee ia iiaeao ia/eiaony n oeeo?u”, //9

“Iaecaanoiue eaeaioeoeeaoi?(u) – “, //10

“Ia iaeaeai eaeaioeoeeaoi? eee OeAC”, //11

“Eaeaioeoeeaoi? ia iiaeao ia/eiaoueny n oeeo?u”,
//12

“Ia iaeaeai eee ia aa?iue ia?aiao?”, //13

“Iaecaanoiay ciaeiaay eiino?oeoeey”, //14

“”}; //15

FILE *fl_t;

int mistake_number[15]; //iannea o?aiyuee eiaeu ioeaie (0 eee 1)

//aaea 1-ioeaea i?enoonaoao, 0 a i?ioeaiii
neo/aa

//mistake_number[i], aaea i iiia? ioeaee ec
mistake

char strange[100]; //ia?a/aiue iaecaanoiuo eaeaioeoeeaoi?ia

//iaeaeaiuo a no?iea ai a?aiy ?acai?a

int s=0; //oaeouay iiceoeey a strange

void main()

{

open_fl();

help_line();

print_page();

work_space();

}

//———————————————————————-
——

// Ioe?uoea oaeea

//———————————————————————-
——

void open_fl(void)

{

FILE *fl;

int i;

window(1,1,80,25);

textbackground(BLACK);

textcolor(WHITE);

clrscr();

_setcursortype(_NOCURSOR);

if((fl_t= fopen(FL_TEST,”w”))== NULL) exit(1);

if ((fl = fopen(FL_NAME,”r”))==NULL)

{

window(18,10,60,16);

textbackground(GREEN);

textcolor(BLACK);

clrscr();

gotoxy(5,2);cprintf(” Iaiiao iaeoe oaee test.513″);

gotoxy(5,3);cprintf(“I?iaa?oa aai iaee/ea ia aeenea”);

gotoxy(5,4);cprintf(” eee nicaeaeoa iiaue”);

gotoxy(3,6);cprintf(“Aeey i?iaeieaeaiey iaaeieoa ethaoth
eeaaeoo”);

getch();

exit(0);

}

for(i=0;i<25;i++){window(40-i,12-i/5,40+i,12+i/5);textbackground(GREEN);textcolor(BLACK);clrscr();delay(7);}textcolor(WHITE);gotoxy(12,2);cprintf("*oaiea no?ie aeey ?acai?a");gotoxy(12,3);cprintf(" i?iecaaaeaiia ec");gotoxy(12,4);cprintf(" oaeea ");gotoxy(12,5);cprintf(" test.513 ");gotoxy(7,8);cprintf(" Aeey i?iaeieaeaiey iaaeieoa ethaoth eeaaeoo");getch();for (i=0; i<20; i++){if (fgets(TEXT[i],78,fl)==NULL) break; // /eoaoue no?ieo oaeea}TEXT[i][0]=NULL;position=0; //iaioeaiea iiceoeee naeaeaa nopaieoefclose(fl);}//---------------------------------------------------------------------- ------// ?aai/ay iaeanoue//---------------------------------------------------------------------- ------void work_space(void){char c;while(1){gotoxy(1,cur_y);c=getch();switch(c){case UP:if(cur_y!=3){cur_y--;print_page();}else{if(position!=0){position--;print_page();cur_y=3;}}break;case DOWN:if(cur_y!=7){cur_y++; if(TEXT[cur_y+position-3][0]==NULL) cur_y--;print_page();}else{cur_y=7; if(TEXT[cur_y+position-2][0]!=NULL){position++;print_page();}}break;case F1:help(1);break;case F2:help(2);break;case F3:help(3);break;case ALTX:window(1,1,80,25);textbackground(BLACK);textcolor(WHITE);fclose(fl_t);clrscr();exit(1);case ESC:window(1,1,80,25);textbackground(BLACK);textcolor(WHITE);clrscr();fclose(fl_t);exit(1);}}}//---------------------------------------------------------------------- ------// ?ania/aouaaao oaeno, auaiaeeo ia ye?ai ioeaee, iaeaeaiiua a ia?aaaouaaaiie// (oaeouae) no?iea//---------------------------------------------------------------------- ------void print_page(){int i,xx=10;puttext(1,1,80,25,screen);for(i=0;i<=15;i++) //i/enoea ianneaa ioeaiemistake_number[i] = 0;strange[0]=NULL;s=0;x=cur_y+position-3;y=0;f=0; fprintf(fl_t,"__________________________________________________________ ____________________\n");fprintf(fl_t,"Ia?aaaouaaai no?i/eo - %s\n",TEXT[x]);scan(); //aucuaaao neaia? aeey ?acai?a no?ieefprintf(fl_t,"\n Iaeaeaiiua ioeaee a no?iea %s\n",TEXT[x]);for(i=0;i<=15;i++)if(mistake_number[i] == 1){gotoxy(4,xx++);printf("%s ",mistake[i]);fprintf(fl_t," %s\n",mistake[i]);if(i==10 && mistake_number[i] == 1){printf(" %s",strange);fprintf(fl_t," %s\n",strange);}}if(xx == 10) //ioeaie iao, o.e. eii?aeeiaou no?iee{ //iaeciaieeenue (xx)gotoxy(4,xx++);printf("%s ",mistake[0]);}textbackground(BLACK);textcolor(WHITE);if(TEXT[0][0]!=NULL){for (i=1;i<6;i++){if(TEXT[i-1+position][0]==NULL) break;gotoxy(1,i+2);puts(TEXT[i-1+position]);}}gotoxy(1,cur_y);textbackground(RED);clreol();puts(TEXT[cur_y+position-3]);}//---------------------------------------------------------------------- ------// Auaiaeeo ia ye?ai oaeno n iiiiuueth//---------------------------------------------------------------------- ------void help_line(void){window(1,1,80,25);textbackground(BLACK);clrscr();textbackground(GREEN);textcolor(BLACK);gotoxy(1,1);clreol();printf(" Borland C++ Aapney oieueei aeey iiapaoipa WHILE");gotoxy(1,25);textbackground(LIGHTCYAN);clreol();cprintf(" F1 - Iiiiuue F2 - A?aiiaoeea F3 - sscue iia?aoi?a ALT+X-Auoiae");gotoxy(1,2);textbackground(LIGHTCYAN);clreol();printf("------------------------------- CIAeA?AEEIIA OAEEA -------------------------------");gotoxy(1,8);textbackground(LIGHTCYAN);clreol();printf("------------------------------ NIIAUAIEss IA IOEAEAO ----------------------------");gotoxy(1,9);gettext(1,1,80,25,screen);gettext(1,9,80,24,screen1);}//---------------------------------------------------------------------- ------// Auaiaeeo ia ye?ai oaeno, a caaeneiinoe io cia/aiey n//---------------------------------------------------------------------- ------void help(int n){char string[4096];gettext(1,8,80,22,string);window(1,8,80,22);textbackground(CYAN);textcolor(BLACK);clrscr();gotoxy(1,1);if(n ==1){cprintf("\n HIAINEAE?NEEE AINOAeA?NOAAHHUE OAOHE*ANEEE OHEAA?NEOAO\n\r\r");cprintf(" Eopniaay paaioa ii aeenoeeieeia NENOAIHIA I?IA?AIIE?IAAHEA\n\r\r");cprintf(" Neioaene/aneee paniiciaaaoaeue\n\n\r\r\r");cprintf(" Eniieuecoaiua eeaaeoe:\r\n");cprintf(" F1 - aeaiiue HELP.\r\n");cprintf(" F2 - apaiiaoeea ycuea.\r\n");cprintf(" F3 - ycue iia?aoi?a.\r\n");cprintf(" Esc - auoiae ec i?ia?aiiu.\r\n");cprintf(" Alt-X - auoiae ec i?ia?aiiu.\r\n\n\n");cprintf(" (c) 1997 Noa?eeia Aeieo?ee Aeaenaiae?iae/");}if(n == 2){cprintf("\n A?AIIAOEEA ssCUEA\n\n\r\r");cprintf(" 1. -> WHILE
()[];\n\r\r”);

cprintf(” 2. -> T| >T | <=T |
>=T | !=T\n\r\r\r”);

cprintf(” 3. T -> O | T+O | T-O | T*O | T/O |
T**O\n\r\r\r”);

cprintf(” 4. O ->() | | \n\r\r\r”);

cprintf(” 5. -> A{A|Oe}\r\r\r\r\n”);

cprintf(” 6. -> Oe{Oe}\r\n”);

cprintf(” 7. ->
([{,}])\r\n”);

cprintf(” 8. -> | \r\n”);

}

if(n == 3)

{

cprintf(“\n ssCUE IIA?AOI?A\n\n\n\r\r”);

cprintf(” WHILE(AB)
[FUNCTION([PAR,PAR,…])];\r\n\n”);

cprintf(” AB – Au?aaeaiea \r\n”);

cprintf(” FUNCTION – ooieoeey\r\n”);

cprintf(” PAR – ia?aiao?u ooieoeee, iiaoo auoue
oeeo?u eee oaeno \r\n”);

cprintf(” eiee/anoai eo ia
ia?aie/aii\r\n\n”);

cprintf(” I?iaaeu iaaeaeo neiaieaie
iaaeiionoeiu\r\n\n\n”);

}

getch();

puttext(1,8,80,22,string);

window(1,1,80,25);

}

//———————————————————————-
——

// Neaie?oao aei iiyaeaiey While

//———————————————————————-
——

int scan()

{

int k,j,w; //n/ao/eee

mistake_number[1]=1;

for(j=0;;j++)

{

if(TEXT[x][j] == NULL) break;

if(TEXT[x][j] == ‘W’)

{

y=j; //anee iaoee W eee w

if(my_while() == 1) break; //oi aucuaaai

} //my_while

if(TEXT[x][j] == ‘w’)

{

y=j;

if(my_while() == 1) break;

}

if(TEXT[x][j] != ‘ ‘)

{

strange[s++]=TEXT[x][j];

mistake_number[10]=1;

}

if(TEXT[x][j] == ‘ ‘)

{

strange[s++]=’,’;

strange[s++]=’ ‘;

}

}

strange[s]=NULL;

return(1);

}

//———————————————————————-
——

// Ia?aaaouaaao While e aucuaaao ia?aaioeo ooieoeee

//———————————————————————-
——

int my_while()

{

char str[10];

int k,j,w; //n/ao/eee

for(w=0;w<5;w++){if(TEXT[x][y] == NULL) break;str[w]=toupper(TEXT[x][y++]); //Toupper - ia?aaiaeeo} //ana aoeau a caaeaaiuastr[w]=NULL;if(strcmp(str,"WHILE") == 0) //Anee While iaeaeai oi i?iecaiaeei{ // aeaeueiaeoee ?acai?fprintf(fl_t,"Iaeaeai While i?iaa?ea ia/aeanue n neiaiea - %c\n",TEXT[x][y]);if(TEXT[x][y] != '(') mistake_number[2]=1;else y++;AB();if(TEXT[x][y] != ')') mistake_number[3]=1;y++;mistake_number[1]=0;FUNC();return(1);}else return(0);}//---------------------------------------------------------------------- ------// Ia?aaioea au?aaeaiey//---------------------------------------------------------------------- ------int AB(){char signal[4]=">‘)

{

y++;

if(TEXT[x][y] == ‘=’) y++;

for(z=0;z<4;z++)if(TEXT[x][y] == signal[z]){mistake_number[14]=1;y++;z=0;}AB();return(1);}if(TEXT[x][y] == '='){y++;if(TEXT[x][y] == '='){y++;}for(z=0;z<4;z++)if(TEXT[x][y] == signal[z]){mistake_number[14]=1;y++;z=0;}AB();return(1);}if(TEXT[x][y] == '!'){y++;for(z=0;z<3;z++)if(TEXT[x][y] == signal[z]){mistake_number[14]=1;y++;z=0;}if(TEXT[x][y+1] == '='){y++;}AB();return(1);}if(TEXT[x][y] == NULL) return(1);return(1);}//---------------------------------------------------------------------- ------// Ia?aaioea oa?ia//---------------------------------------------------------------------- ------int TERM(){fprintf(fl_t,"I?iaa?ea ia TERM\n");O();if(TEXT[x][y] == '/'){y++;TERM();}else if(TEXT[x][y] == '*'){y++;if(TEXT[x][y] == '*') y++;TERM();}else if(TEXT[x][y] =='+'){y++;if(TEXT[x][y] == '+' && TEXT[x][y+1] == ')' ){ //aiciiaeia ia?aaioea au?aaeaieyy++; //oeia y++return(0); //eee y+++e}if(TEXT[x][y] == '+'&& TEXT[x][y+1] == '+') y+=2;TERM();}else if(TEXT[x][y] =='-'){y++;if(TEXT[x][y] == '-' && TEXT[x][y+1] == ')' ){ //aeey y--y++;return(0);}if(TEXT[x][y] == '-'&& TEXT[x][y+1] == '-') y+=2;TERM();}else if(TEXT[x][y] ==NULL ) return(1);else if(TEXT[x][y] != '+' && TEXT[x][y]!='*' && TEXT[x][y]!=')' && TEXT[x][y] != '/' && TEXT[x][y]!='-' && TEXT[x][y] != '<' && TEXT[x][y]!='>‘ && TEXT[x][y]!=’!’ && TEXT[x][y]!=’ ‘&& TEXT[x][y]!=’=’)

{

mistake_number[7]=1;

AB();

}

return(1);

}

//———————————————————————-
——

// Ia?aaioea iia?aiaea

//———————————————————————-
——

int O()

{

fprintf(fl_t,”I?iaa?ea ia O\n”);

if(TEXT[x][y] == ‘(‘)

{

y++;

if(TEXT[x][y] == ‘)’)

{

mistake_number[4]=1;

y++;

}

else

{

AB();

if(TEXT[x][y] == ‘(‘)

{

AB();

}

if(TEXT[x][y] != ‘)’)

{

mistake_number[3]=1;

y++;

}

else y++;

}

}

else

{

if(IDENT() == 0)

if(ZBZ() == 0)

if(f==0) mistake_number[11]=1;

return(0);

}

return(0);

}

//———————————————————————-
——

// Ia?aaioea eaeaioeoeeaoi?a

//———————————————————————-
——

int IDENT()

{

fprintf(fl_t,”I?iaa?ea ia IDENT, oaeouee neiaie –
%c\n”,TEXT[x][y]);

if((isalpha(TEXT[x][y])) != NULL)

{

while(isalpha(TEXT[x][y]) || isdigit(TEXT[x][y]))

y++;

return(1);

}

else return(0);

}

//———————————————————————-
——

// Oeaeia aac ciaea

//———————————————————————-
——

int ZBZ()

{

fprintf(fl_t,”I?iaa?ea ia OeAC, oaeouee neiaie –
%c\n”,TEXT[x][y]);

if((isdigit(TEXT[x][y])) != NULL)

{

y++;

while(1)

{

if((isalpha(TEXT[x][y])) != NULL)

{

/*Anee iaeaeai eaeaioeoeeaoi?,*/ if(f==0) mistake_number[12]=1;

/*ia/eiathueeny n oeeo?u, */ else mistake_number[9]=1;

/*oi ioeaea: */ while(isalpha(TEXT[x][y]) ||
isdigit(TEXT[x][y]))

/*anee f=0 oi a eaeaioeoeeaoi?a*/ y++;

/*anee f=1 oi a ia?aiao?a */ return(1);

/* ooieoeee */ }

if((isdigit(TEXT[x][y])) == NULL) break;

y++;

}

return(1);

}

else return(0);

}

//———————————————————————-
——

// Ia?aaioea ooieoeee

//———————————————————————-
——

int FUNC()

{

f=1;

fprintf(fl_t,”I?iaa?ea ia FUNC, oaeouee neiaie –
%c\n”,TEXT[x][y]);

for(;;y++)

if(TEXT[x][y] != ‘ ‘) break;

if(IDENT()==0)

{

mistake_number[6]=1;

while(isalpha(TEXT[x][y]) || isdigit(TEXT[x][y]))

y++;

}

if(mistake_number[6] ==0)

if(TEXT[x][y] =='(‘)

{

y++;

if(TEXT[x][y] == ‘)’)

{

mistake_number[4]=1;

y++;

}

else while(6)

{

if(PAR() != 0)

{

if(TEXT[x][y] == ‘)’)

{

y++;

break;

}

if(TEXT[x][y] == ‘;’) break;

if(TEXT[x][y] == ‘,’) y++;

}

else

{

mistake_number[13]=1;

break;

}

}

}

else

{

mistake_number[2]=1;

mistake_number[13]=1;

}

if(mistake_number[13]==1)

{

for(;;y++)

{

if(TEXT[x][y] == NULL)

{

mistake_number[5]=1;

mistake_number[3]=1;

break;

}

if(TEXT[x][y] == ‘;’)

{

mistake_number[3]=1;

break;

}

if(TEXT[x][y] == ‘)’)

{

y++;

break;

}

}

}

if(TEXT[x][y] != ‘;’) mistake_number[5]=1;

return(1);

}

//———————————————————————-
——

// Ia?aaioea ia?aiao?ia ooieoeee

//———————————————————————-
——

int PAR()

{

fprintf(fl_t,”I?iaa?ea ia PAR, oaeouee neiaie –
%c\n”,TEXT[x][y]);

if(IDENT() == 0)

if(ZBZ() == 0)

{

mistake_number[13]=1;

return(0);

}

return(1);

}

Nienie eeoa?aoo?u:

Ae. A?en Eiino?oe?iaaiea eiiieeyoi?ia aeey oeeo?iauo au/eneeoaeueiuo
iaoei. I., Ie?, 1975.

Eaaaaeaa A.I. Aaaaeaiea a nenoaiu i?ia?aiie?iaaiey. I., «Noaoenoeea»,
1975.

Oi?ieeia TH.A., Oaaae A.?. Iaoiaee/aneia iiniaea aeey auiieiaiey
eo?niaie ?aaiou ii nenoaiiiio i?ia?aiie?iaaieth. Iiaineae?ne, 1992.

PAGE

PAGE 27

Похожие документы
Обсуждение
    Заказать реферат
    UkrReferat.com. Всі права захищені. 2000-2019