28 lines
1.3 KiB
Plaintext
28 lines
1.3 KiB
Plaintext
|
nodebug.
|
||
|
[parser].
|
||
|
trace.
|
||
|
transform([ 3, -, 5 ], R), parseLL(R, ProdSeq).
|
||
|
cuccccccccccccccccccccccccccccccccccccc
|
||
|
|
||
|
transform([ 3, -, 5 ], R), parseAndSolve(R, ProdSeq, V).
|
||
|
|
||
|
|
||
|
attribute(0,[non(s,V),non(e,V)]). % s -> e
|
||
|
attribute(1,[non(e,V),non(t,Vt),non(tt,Vtt)]) :- % e -> t tt
|
||
|
V is Vt - Vtt.
|
||
|
attribute(2,[non(tt,V),term(minus,_),non(t,Vt),non(tt,Vtt)]) :- % tt -> - t tt
|
||
|
V is Vt - Vtt.
|
||
|
attribute(3,[non(tt,0),term(eps,_)]). % tt -> ϵ
|
||
|
attribute(4,[non(t,V),term(num,Vnum),non(ft,Vft)]) :- % t -> num ft
|
||
|
V is Vnum * Vft.
|
||
|
attribute(5,[non(ft,V),term(times,_),term(num,Vnum),non(ft,Vft)]) :- % ft -> * num ft
|
||
|
V is Vnum * Vft.
|
||
|
attribute(6,[non(ft,1),term(eps,_)]). % ft -> ϵ
|
||
|
|
||
|
attribute(0,[non(s,V),non(e,V)]). % s -> e
|
||
|
attribute(1,[non(e,Vt - Vtt),non(t,Vt),non(tt,Vtt)]).
|
||
|
attribute(2,[non(tt,Vt - Vtt),term(minus,_),non(t,Vt),non(tt,Vtt)]).
|
||
|
attribute(3,[non(tt,0),term(eps,_)]). % tt -> ϵ
|
||
|
attribute(4,[non(t,Vnum * Vft),term(num,Vnum),non(ft,Vft)]).
|
||
|
attribute(5,[non(ft,Vnum * Vft),term(times,_),term(num,Vnum),non(ft,Vft)]).
|
||
|
attribute(6,[non(ft,1),term(eps,_)]). % ft -> ϵ
|