Skip to content

Commit 90222cd

Browse files
committed
ajuste no parsing
1 parent 828a4ed commit 90222cd

2 files changed

Lines changed: 25 additions & 15 deletions

File tree

Imperativa1/src/li1/plp/expressions2/expression/ExpTernaria.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public abstract class ExpTernaria implements Expressao {
3232
private String operador1;
3333

3434
/**
35-
* Operador 1 desta expressao ternaria
35+
* Operador 2 desta expressao ternaria
3636
*/
3737
private String operador2;
3838

Imperativa1/src/li1/plp/imperative1/parser/Imperative1.jj

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -539,14 +539,29 @@ Expressao PExpBinaria() :
539539
}
540540
}
541541

542+
Expressao PExpBase() :
543+
{
544+
Expressao retorno;
545+
}
546+
{
547+
(
548+
LOOKAHEAD (2)
549+
retorno = PExpUnaria()
550+
| LOOKAHEAD (PExpPrimaria() (<OR> | <AND> | <MINUS> | <PLUS> | <EQ>| <CONCAT>))
551+
retorno = PExpBinaria()
552+
| retorno = PExpPrimaria()
553+
)
554+
{ return retorno; }
555+
}
556+
542557
Expressao PExpTernaria() :
543558
{
544559
Expressao esq;
545560
Expressao mei;
546561
Expressao dir;
547562
}
548563
{
549-
esq = PExpPrimaria()
564+
esq = PExpBase()
550565
<HOOK>
551566
mei = PExpressao()
552567
<COLON>
@@ -562,7 +577,7 @@ ExpSoma PExpSoma() :
562577
{
563578
esq = PExpPrimaria()
564579
<PLUS>
565-
dir = PExpressao()
580+
dir = PExpBase()
566581
{return new ExpSoma(esq, dir);}
567582
}
568583

@@ -574,7 +589,7 @@ ExpSub PExpSub() :
574589
{
575590
esq = PExpPrimaria()
576591
<MINUS>
577-
dir = PExpressao()
592+
dir = PExpBase()
578593
{return new ExpSub(esq, dir);}
579594
}
580595

@@ -587,7 +602,7 @@ ExpAnd PExpAnd() :
587602
{
588603
esq = PExpPrimaria()
589604
<AND>
590-
dir = PExpressao()
605+
dir = PExpBase()
591606
{return new ExpAnd(esq, dir);}
592607
}
593608

@@ -600,7 +615,7 @@ ExpOr PExpOr() :
600615
{
601616
esq = PExpPrimaria()
602617
<OR>
603-
dir = PExpressao()
618+
dir = PExpBase()
604619
{return new ExpOr(esq, dir);}
605620
}
606621

@@ -612,7 +627,7 @@ ExpEquals PExpEquals() :
612627
{
613628
esq = PExpPrimaria()
614629
<EQ>
615-
dir = PExpressao()
630+
dir = PExpBase()
616631
{return new ExpEquals(esq, dir);}
617632
}
618633

@@ -625,7 +640,7 @@ ExpConcat PExpConcat() :
625640
{
626641
esq = PExpPrimaria()
627642
<CONCAT>
628-
dir = PExpressao()
643+
dir = PExpBase()
629644
{return new ExpConcat(esq, dir);}
630645
}
631646

@@ -635,15 +650,10 @@ Expressao PExpressao() :
635650
}
636651
{
637652
(
638-
LOOKAHEAD (PExpPrimaria() <HOOK>)
653+
LOOKAHEAD (PExpBase() <HOOK>)
639654
retorno = PExpTernaria()
640655
|
641-
LOOKAHEAD (2)
642-
retorno = PExpUnaria()
643-
| LOOKAHEAD (PExpPrimaria() (<OR> | <AND> | <MINUS> | <PLUS> | <EQ>| <CONCAT>))
644-
retorno = PExpBinaria()
645-
|
646-
retorno = PExpPrimaria()
656+
retorno = PExpBase()
647657
)
648658
{
649659
return retorno;

0 commit comments

Comments
 (0)