@@ -6,10 +6,10 @@ import TeX from "@matejmazur/react-katex";
66interface State {
77cfg :CFG . ContextFreeGrammar ;
88steps :{
9- bin :Array < CFG . ContextFreeGrammar > ;
10- del :Array < CFG . ContextFreeGrammar > ;
11- unit :Array < CFG . ContextFreeGrammar > ;
12- term :Array < CFG . ContextFreeGrammar > ;
9+ bin :Array < [ CFG . ContextFreeGrammar , string ] > ;
10+ del :Array < [ CFG . ContextFreeGrammar , string ] > ;
11+ unit :Array < [ CFG . ContextFreeGrammar , string ] > ;
12+ term :Array < [ CFG . ContextFreeGrammar , string ] > ;
1313} ;
1414}
1515
@@ -30,22 +30,22 @@ export class CFGCNF extends Component<{}, State> {
3030}
3131
3232private transform ( ) :void {
33- const bin = new Array < CFG . ContextFreeGrammar > ( ) ;
34- let del = null ;
35- let unit = null
36- let term = null ;
33+ const bin = new Array < [ CFG . ContextFreeGrammar , string ] > ( ) ;
34+ let del : Array < [ CFG . ContextFreeGrammar , string ] > = null ;
35+ let unit : Array < [ CFG . ContextFreeGrammar , string ] > = null
36+ let term : Array < [ CFG . ContextFreeGrammar , string ] > = null ;
3737
3838try {
39- let cfg = this . state . cfg . bin ( s => bin . push ( s ) ) ;
39+ let cfg = this . state . cfg . bin ( ( cfg , desc ) => bin . push ( [ cfg , desc ] ) ) ;
4040if ( cfg != null ) {
41- del = new Array < CFG . ContextFreeGrammar > ( ) ;
42- cfg = cfg . del ( s => del . push ( s ) ) ;
41+ del = new Array < [ CFG . ContextFreeGrammar , string ] > ( ) ;
42+ cfg = cfg . del ( ( cfg , desc ) => del . push ( [ cfg , desc ] ) ) ;
4343if ( cfg != null ) {
44- unit = new Array < CFG . ContextFreeGrammar > ( ) ;
45- cfg = cfg . unit ( s => unit . push ( s ) ) ;
44+ unit = new Array < [ CFG . ContextFreeGrammar , string ] > ( ) ;
45+ cfg = cfg . unit ( ( cfg , desc ) => unit . push ( [ cfg , desc ] ) ) ;
4646if ( cfg != null ) {
47- term = new Array < CFG . ContextFreeGrammar > ( ) ;
48- cfg . term ( s => term . push ( s ) ) ;
47+ term = new Array < [ CFG . ContextFreeGrammar , string ] > ( ) ;
48+ cfg . term ( ( cfg , desc ) => term . push ( [ cfg , desc ] ) ) ;
4949}
5050}
5151}
@@ -69,10 +69,10 @@ export class CFGCNF extends Component<{}, State> {
6969switch ( type ) {
7070case CopyType . LaTeX :
7171text = [
72- this . state . steps . bin . map ( cfg => cfg . formatLaTeX ( ) ) . join ( " \\\\[1em]\n" ) ,
73- this . state . steps . del . map ( cfg => cfg . formatLaTeX ( ) ) . join ( " \\\\[1em]\n" ) ,
74- this . state . steps . unit . map ( cfg => cfg . formatLaTeX ( ) ) . join ( " \\\\[1em]\n" ) ,
75- this . state . steps . term . map ( cfg => cfg . formatLaTeX ( ) ) . join ( " \\\\[1em]\n" ) ,
72+ this . state . steps . bin . map ( ( [ cfg , _ ] ) => cfg . formatLaTeX ( ) ) . join ( " \\\\[1em]\n" ) ,
73+ this . state . steps . del . map ( ( [ cfg , _ ] ) => cfg . formatLaTeX ( ) ) . join ( " \\\\[1em]\n" ) ,
74+ this . state . steps . unit . map ( ( [ cfg , _ ] ) => cfg . formatLaTeX ( ) ) . join ( " \\\\[1em]\n" ) ,
75+ this . state . steps . term . map ( ( [ cfg , _ ] ) => cfg . formatLaTeX ( ) ) . join ( " \\\\[1em]\n" ) ,
7676] . join ( " \\\\[3em]\n\n" ) ;
7777break ;
7878default :
@@ -130,12 +130,14 @@ export class CFGCNF extends Component<{}, State> {
130130< >
131131< h4 > Bin</ h4 >
132132{
133- this . state . steps . bin . map ( ( cfg , i ) =>
134- < CFGTable
135- key = { i }
136- cfg = { cfg }
137- readonly = { true }
138- />
133+ this . state . steps . bin . map ( ( [ cfg , desc ] , i ) =>
134+ < div key = { i } >
135+ < p > { desc } </ p >
136+ < CFGTable
137+ cfg = { cfg }
138+ readonly = { true }
139+ />
140+ </ div >
139141)
140142}
141143< br />
@@ -147,12 +149,14 @@ export class CFGCNF extends Component<{}, State> {
147149< >
148150< h4 > Del</ h4 >
149151{
150- this . state . steps . del . map ( ( cfg , i ) =>
151- < CFGTable
152- key = { i }
153- cfg = { cfg }
154- readonly = { true }
155- />
152+ this . state . steps . del . map ( ( [ cfg , desc ] , i ) =>
153+ < div key = { i } >
154+ < p > { desc } </ p >
155+ < CFGTable
156+ cfg = { cfg }
157+ readonly = { true }
158+ />
159+ </ div >
156160)
157161}
158162< br />
@@ -164,12 +168,14 @@ export class CFGCNF extends Component<{}, State> {
164168< >
165169< h4 > Unit</ h4 >
166170{
167- this . state . steps . unit . map ( ( cfg , i ) =>
168- < CFGTable
169- key = { i }
170- cfg = { cfg }
171- readonly = { true }
172- />
171+ this . state . steps . unit . map ( ( [ cfg , desc ] , i ) =>
172+ < div key = { i } >
173+ < p > { desc } </ p >
174+ < CFGTable
175+ cfg = { cfg }
176+ readonly = { true }
177+ />
178+ </ div >
173179)
174180}
175181< br />
@@ -181,12 +187,14 @@ export class CFGCNF extends Component<{}, State> {
181187< >
182188< h4 > Term</ h4 >
183189{
184- this . state . steps . term . map ( ( cfg , i ) =>
185- < CFGTable
186- key = { i }
187- cfg = { cfg }
188- readonly = { true }
189- />
190+ this . state . steps . term . map ( ( [ cfg , desc ] , i ) =>
191+ < div key = { i } >
192+ < p > { desc } </ p >
193+ < CFGTable
194+ cfg = { cfg }
195+ readonly = { true }
196+ />
197+ </ div >
190198)
191199}
192200< br />