• Nenhum resultado encontrado

J. Braz. Comp. Soc. vol.9 número1

N/A
N/A
Protected

Academic year: 2018

Share "J. Braz. Comp. Soc. vol.9 número1"

Copied!
14
0
0

Texto

(1)

!

+

8

-/

-

7 /

,

9:

;

<

-9

:/ 8

7

=

3

>

Æ

?

8

< #

6

Parser Generator

Carlos Camarão

Universidade Federal

de Minas Gerais

31270-010 - Belo Horizonte

MG - Brasil

camarao@dcc.ufmg.br

Lucília Figueiredo

Universidade Federal

de Ouro Preto

35100-000 - Ouro Preto

MG - Brasil

lucilia@dcc.ufmg.br

Hermann Rodrigues

Universidade Federal

de Minas Gerais

31270-010 - Belo Horizonte

MG - Brasil

hermann@dcc.ufmg.br

#$ %&℄ #%( %) * )℄ +

,

! -. $/

-. 0/

.123!$44%"3#5℄

6

6%

! - /

7

!-/

!

Abstract

(2)

<

½

½

-

½

/ +

"

<

8

- /

@

A

@ 7

B

+

<

- /

8

BA-/

8 7

-

/ +

7

-/

C!

D

E

>%

8

"

8

>%<

·

-

/D

D

+

Æ

%

+

-

/

,!

<

1

"

-

/ +A

<

>

#

(3)

> #

#

8

> C

$%!- C !/

3

- #$ %0℄/ &

&

#%*℄-

&

& /

F

- /

22-/

2G-/ H

$ " "%

D

$ %

- / ,

>$

!

7-

/

"

!

<

'

'

%

>

6II(

#

8

!

$ # %

!

E

>$<

(

8 '

''(

A3 Æ

<

E

,

1 !

H

(4)

) $ *%

)( $ *%

$ ) )( %

) $ *%

*

*

>5<

3 / Æ

+

22-/

2G-/

, <

+) +) +) +)(

+) *

*

+)

7

>5

"

,

,$ - %-$ - %℄ =

D

F ,

.5!

.0

.&

.*

H

<

; F

/012 Î

Î

J

J

£

7

-JÎ/

£

7

-JÎ/

£

7

7 -

/

!

- 33 / H

.&

<<6 ¼

<<6 6 ½

½

6-JÎÈ/

>0

-/ 7

- 7

97 7 : @

¼

6

¼

/

È-/

7

- / .

.5

-/ >

>&

(5)

##℄℄

6 ##6 ½ ½ ℄℄ -%/ ½ ½ 6-/

##6℄℄

6 ### ½ ℄℄ ½ ½ ## ℄℄ ℄ -$/ 6 ½ ½ ¾ ¾ ·½ J

6%I%

-/6

½ ½ ¾ ¾ ·½ J 6%

##6 ½ ½ ℄℄ 6

##6 ½

½ ℄℄

"- ½

/

##6 ¾

¾ ℄℄

"- ½

/ -

¾ /

##6 ℄℄ - ½ / !!! - ½ / - /

"-

/

6%

-5/

-/6

-/ 6 /

! . 7 > 7 Æ 7 2 .& 2 <

-/ 6

-/ 6

-/ 6

-/

-/ 6 - 6/

-/ 6

½ ½ 6-/ - / % - / D "

1 1 1 #

4

! E

>*

"

"

" "

$ 5 " 5 #

"%

!

4

"

" "

$ 3 " %

,℄ ! >*< 2 #%℄ + 8

Figure 4: Semantics of Mímico’s input

Figure 5:

parsed

substring

(6)

-/ -/

-Ë/ Ë

-Ë/ Ë

-Ë/

Ë Ë

6 ½ ½ È-/ ËË ¼ Ë/ 6) Ë ¼

6 Ë

6 % -/ >)< - / H ,

>7

-/ - / > >)

+ 6

-/ + 7 > (

>(-

/ 0 - 0

Î/ 6 %-

>K/ 8

- / >K

6 0

0 ¼ ¼ 6 % 6 % 7 -0

Î0

6J

/ # $% $ > ( ¼

/ 2

6 % 2 # ¼ ℄ - / ¼ / ¼ / ¼ / ¼ ¼ ¼ 2 ¼ 2 < ¼ ,℄ ¼ 2 ¼ 2 < ¼ ,℄ 2 0 1 2 0 1

6% 1

6 0 0 Î ¼ ¼ ¼ ¼ ¼

>K< &$

Figure 7: Function

first

G

Figure 8: Form of directly left-recursive productions

(7)

6%<

6

/

¼

5 "

,57- "70

0

/

¼

5 "

,57℄

" 5

-

6%/

< / %

/

D/0

2

0

2

0

-6%/

<

/ / # (8

/

/ 4

2

D

Æ "

-/ <

/ $ / 8 (

$ % #

# %

/ $/- %

/ 4

1

>%4

H <

' ( 2

¼

7

½

>

¼

##℄℄

¼

6##℄℄

½

$ 5 " " # (85

%

$ 3 %

,℄

! 4

4

!

>%4< E

< .

½

¼

¼

H 6 6 %

, % %

- 3

/ H

0

½

½

½

¼ ½

¼ ½

½ 2

½

1

½

0

06 J

£

H

##6 ¼

℄℄

¼

6##/℄℄

½

##0℄℄

¼

6##0℄℄

½

J

£

-

½

B

¼

/

-

Æ /<

)( 8" 5 "7

$ "% $ 5 $ "%%5

2 6##6

¼ ℄℄

¼

<

##℄℄ ¼

6 ##℄℄

½ 6

¼

-0/ 6

¼

-/6

(8)

##℄℄

¼

6##60 ¼

℄℄

¼

6##6 ¼

℄℄ ¼

6

< ##℄℄

½

6## / ℄℄

½

6 -##/℄℄

½ / -## ¼ ℄℄ ½ /

5 " 6#5"0℄

.## ¼ ℄℄ ½ 6,℄ ##℄℄ ½

6 ,℄6

¼

-/6

H

J

£

/ 6

½ ¾ ¼ 0/6 6% ¼

-0/

¼

-/6

##℄℄

¼ 6 ##℄℄

½

6 /

> 6 %

½ 0/ 6 2

6 ##/℄℄ ½

6 ##0℄℄

¼

6

% H

<

* 1< 6% <

##℄℄

¼

6##60 ¼

℄℄

¼

6##60℄℄ ¼ 6###℄℄

¼ ½ 0℄ ##℄℄ ¼ 6# ½ 0℄ H ##℄℄ ½

6##6/ ¼ ℄℄ ½

6 -##/℄℄

½ / -## ¼ ℄℄ ½ /

5 " 6#5"0℄

F< ## ¼ ℄℄ ½

6## ¼ 62 ¼ 2< ¼ ℄℄ ½ 62<

¼ ###2℄℄

½ 2 ##

¼ ℄℄ ½ ¼ ℄

6##2℄℄ ½ 3 ,℄ 6# ½ ℄ ## ¼ ℄℄ ½

6## ¼ ,℄℄℄ ½ 6,℄ ##℄℄ ½

6 -##/℄℄ ½

/# ½

6 -

½ /,℄ 6 ½ 6# ½ 0℄

* 8 H<

##℄℄

¼

6##60 ¼

℄℄

¼

6##60℄℄ ¼ 6###℄℄

¼ ½ ¡¡¡ ½

##0℄℄

¼

0℄

6###℄℄ ¼ ½ ¡¡¡ ½ 0℄ ##℄℄ ½

6##6/ ¼ ℄℄ ½ 6

< 6 -##/℄℄

½ /-## ¼ ℄℄ ½ /

5 "6#5"0℄

1 ##℄℄ ¼ ½ ¡¡¡ ½ 6##℄℄

½ ½ ¡¡¡ ½

##0℄℄ ¼

6##0℄℄ ½ < ###℄℄ ¼½¡¡¡ ½

##0℄℄ ¼

0℄6

###℄℄

½½¡¡¡ ½

##0℄℄ ½ 0℄ . ##℄℄ ½½¡¡¡ ½ 6 -##/℄℄ ½ /-## ¼ ℄℄ ½ ½ ¡¡¡ ½ / < ##℄℄ ¼

6# -##/℄℄ ½ / -## ¼ ℄℄ ½½¡¡¡ ½ /

##0℄℄ ½ 0℄ 6 -##/℄℄ ½ /-## ¼ ℄℄ ½½¡¡¡ ½ / / %##℄℄ ¼ 6##℄℄

½ >( >%% 6 ½ 0 ½ ½ 0 ½ ¼ ½ ¼ 6% 6% 7 -0 0 6 J · /

(( )$% -7

(9)

/ ¼ ½

¼¼ ½

¼

¼¼

-¼ ½

¼¼ ½

/ -¼

¼¼

/6

-/

>%$< + $

> K

/ >%$

-/

-/ <

-/ 6

-/

-Ë/6 Ë

½ Æ

¾ Æ

½

½

6È-/

Æ7

6%

6

6//

-/Ë/

6//

/ Ë

-//

/

8

A

D

9 : ;" $%

: : : $%

:

: 3 , )* ℄

;" ;" ;" $%

;"

;" ' ,

< ' '

<

' +=)

) )> '

=! ℄

> %5< , - ./$$

8

7

> >%5

;

+ C#!C℄!

.

!

! >

>%5

:;":9;"

>%0

8

9 ,:

+

Figure 12: Handling indirect left-recursion

(10)

!

8

9

>

.

!

?<

" "

$

" "

$%%

$

$%%

$

$%%

@ 3

$ )* %

" AAA

AAA AAA

(

+

-#%5%$℄/

"

>

> %& !

;" $ ;" % AAA

B $ ;" % AAA

,

B , B

(" ,

>%*

8

+ 8=

!

6

,

+ 7

9D 7

Figure 14: Compiler for tiny language

(11)

"

@ $

" "

@ %

$ AAA%

"

"

@ $

" "

@ %

$ AAA%

$

%

$B

%

(0 1

%

!

"

- # 8

/

#

8

$ %

8

F

-

!

/

7

8

@ 7

>

7

>%)

6

½

½

½

½

½

¼ ½

¼

6%

J

6 ½

½

J

6%

Î 6%

(2 34 $%$

/1

E

> %( H

D

<

A #

A

A 8

$ %

# 8

>%K 3

@@

L D 5

C

"

( ,

Figure 16: Strict parsing and the use of context sensitive

conditions for parsing control

(12)

3 8

G <

,

>

> %K

D

( D C D

(

(

( .

(

2

>%(

,

8 9:

8

-/

> <

#

8

$ %

A #

A 8

$ %

. 9

:

-

/B

-

/ "

.

@ E $, # ℄ %

# ) 5

# $#%

4

( @ E $, # ℄ %

# ) 5

# $#%

4 (

( @ E

$ 4 ( %

@ E ($, ℄ %

) 5

$%

(

4

( @ E D$, ℄ %

) 5

$%

4 (

( @ E

$ 4 ( %

( @ E D

8 ) 5

! 8

( @ E

$ 8 ( %

D

D @ $ $ :!%%

$ %

C

C ! $

@ E ,℄

! %

(13)

$,℄%

@ E $, # ℄ %

# ) 5

#

( @ E

$ # ( %

@ E ($, ℄ %

) 5

( @ E

$ ( %

(

D @ E D

8 ) 5

! 8

( @ E

$ 8 ( %

D

D @ $ $ :!%%

$ %

C

C ! $

@ E ,℄

! %

> %K< 1

% /1

H

+

MG2

H

+

H

- /

<

,

22-/2G-/

+

!

22-/

2G-/ >

N

Æ

!

Æ

-#%0℄/

;

-

7/

!

;

+ L

- #%4( %% &℄/ H

N #%4℄

#&℄ Æ

#%0 K0℄ Æ

/ =

8

+

> < /

,

/

/ 9 :

(14)

#%℄ G . + O + PB ; M

!"

! +H %K(*

#$℄ G1#$

% 3 %KK( $

#5℄ " "Q 2 > +

"" " 8&

'()*+,,- ./(0 '

)1*0R)K$44%

#0℄ " 2, 2 > 8

$ $2 # ' $

) .)3' -4++

'/ 1%KKK

#&℄ +E . < 3

E <SS SS

$444

#*℄ E

5 $ $<$5$R

505%KK$

#)℄ E ?L

F=".GK*0%KK*

#(℄ 326 783

%K(K

#K℄ ;2L 3

<SS SQS

#%4℄ PG2 ;1

)8 9 =!G T+%KK$

#%%℄ + 8

" E . 8 &

'()*+,,,.#/(0 '

)1$&KR$**$444

#%$℄ 3G U+

-/< -/

8 #

%KK0

#%5℄ 3 G U + < +

-/ ' :

;$&-)/<)(KR(%4%KK&

#%0℄ .; . 3 "

8 < '#7)<3 % =

%%5R%$($444

#%&℄ . % ! $

+H %KKK

#%*℄ 3 H

8$ )

< )3' +,- %%5R

%$(%K(&

#%)℄ 3 H "

''$-0/<0*%R

0K5%KK4

#%(℄ 3 H > 3

Imagem

Figure 1: A recognizer for a +
Figure 2: Counting the number of a’s
Figure 3: Program for recognizing palindromes
Figure 6: Program for counting b’s in {ab*}
+7

Referências

Documentos relacionados

Theorem 4.2 Regular translations realized by state- deterministic finite transducers are inferable in linear time from positive samples only.. Almost state-deterministic

Therefore, it allows a better delay control for real-time traffic in high load situations and a geater channel use for best effort traffic when low real-time traffic is present in

[r]

Proof obligations containing set theory constructs are translated to first-order logic with equality aug- mented with (an extension of) the theory of arrays with extensionality.

For example, in figure 2 we show an example of similarity with respect to logical connectives between the formulas and (for legibility reasons, each represents a ground

In the previous section we introduce Phi–calculus as a model for the design of DLEs under a particular perspective: the one of the exchanges taking place between a

[r]

This paper presents ODEd, an ontology editor that supports the definition of con- cepts, relations and properties, using graphic representations, besides promoting automatic