-, . ' . , . - , # #, ##. , , begin. ! , . #, \ ! , , \. :
#Pascal - # program (# #) ##.
Java- , , .
. class MyLang . , , , , .
, (, , ).
Class MyLang
, class MyLang :
private int axioma; | // . | |
private boolean create; | // , true | |
private int LLK; | // LLK- | |
private LinkedList<Node> language; | // | |
private LinkedList<TableNode> lexemaTable; | // | |
private int[] terminals; | // | |
private int[] nonterminals; | // | |
private int[] epsilonNerminals; | // - | |
private LlkContext[] termLanguarge; | // , , termLanguarge[i] , terminals[i] | |
private LlkContext[] firstK; | // firstk, nonterminals, firstk[i] Firstk nonterminals[i]. | |
private LlkContext[] followK; | // | |
private LinkedList<LlkContext>[] LocalkContext; | // , LocalkContext[i] Localk nonterminals[i]. | |
private int[] uprTable; | // , , (terminals.length+1), - nonterminals.length. |
|
|
: public MyLang(String fileGramma, int llk).
, () MyLang LinkedList<Node> language . Node. , . public int getAxioma().
Firstk (Ai), Followk(Ai), Firstk(w) Fllowk(Ai) ( Ai -> w) LlkContext.
Localk(S,Ai) LinkedList<LlkContext >, () LlkContext.
MyLang :
, :
public boolean isCreate(); // , complite MyLang
public LinkedList<LlkContext>[] createLocalK();// Localk(S,Ai)
public boolean llkCondition(); // LL(k) -
public boolean createNonProdRools();//
public boolean createNonDosNeterminals();//
public boolean leftRecursNonnerminal();// -
public boolean rightRecursNonnerminal();// -
public LlkContext[] firstK();(); // Firstk (Ai),
public LlkContext[] followK();// Followk (Ai),
public void firstFollowK(); // Firstk (w) +k Followk (Ai)
public int[] createEpsilonNonterminals();// -
private int[] createTerminals(); //
private int[] createNonterminals(); //
public boolean strongLlkCondition(); // LL(k)-
public int[] createUprTable(); // LL(1)-
public int[] createUprTableWithCollision(); // LL(1)- , LL(1)- , LL(2)-. , (-1).
:
public int getAxioma();
public void setLocalkContext(LinkedList<LlkContext>[] localK); // MyLang Localk; , set MyLang, get .
public LinkedList<LlkContext>[] getLocalkContext();
public int[] getUprTable();
public LlkContext[] getFirstK();
public void setFirstK(LlkContext[] first);
public void setUprTable(int[] upr);
public LlkContext[] getFollowK();
public void setFollowK(LlkContext[] follow);
public int getLlkConst();
public LlkContext[] getLlkTrmContext(); // . I- i- ()
|
|
public String getLexemaText(int code); //
public int[] getTerminals()
public int[] getNonTerminals()
public int[] getEpsilonNonterminals()
public LinkedList<Node> getLanguarge()
public void setEpsilonNonterminals(int[] eps)
, ( ) :
public void printLocalk();
public void printTerminals();
public void printNonterminals();
public void prpintRoole(Node nod);
public void printFirstkContext()
public void printFirstFollowK()
public void printFirstFollowForRoole()
public void printFollowkContext()
public void printEpsilonNonterminals()
public void printGramma().
Class Node
lass Node LinkedList<Node> language. Node:
private int[] roole; // . . 䒺 , .
private int teg; // , .
private LlkContext firstFollowK; // Firstk(w)+k Followk(Ai) ( Ai-> w) .
, :
public void addFirstFollowK(LlkContext rezult);
public LlkContext getFirstFollowK();
public int[] getRoole();
Class LlkContext
lass LlkContext . (int []). - new int[0] ( Java .
public LlkContext(); //
public boolean wordInContext(int[] word); //
public int[] getWord(int index); // index . .
public int minLengthWord(); //
public int calcWords(); //
public boolean addWord(int[] word); // . . - true.
Class TableNode
lass TableNode . :
String lexemaText; //
int lexemacode; //
static int numarator; //
0x80000000, 0x10000000.
:
public TableNode (String lexema, int lexemaType);
1
1. . ' . : . - MyLang;
2. . , ;
3. . .
4. , L(G) .
5. -. - MyLang;
6. - .
7. - .
8. ** ( ), .
9. ** ( ), .
2
1. Firstk(Ai), Ai Î N. - MyLang.
|
|
2. Follow(Ai), Ai Î N. - MyLang.
3. Firstk(w) Ai -> w, Ai Î N. - MyLang
4. Firstk(w),+k Follow(Ai), Ai -> w, Ai Î N. - MyLang.
5. , LL(1)-.
6. , LL(k)- ( k=2);
7. , LL(k)- ( k=3);
8. LL(1)- .
9. ** Localk(S,Ai), Ai Î N. - MyLang.
10. **, LL(k)- (k>1).
3
1. Pl/0 .
2. Pl/0 .
3. Pl/0 ( );
4. Pascal .
5. Pascal .
6. Pascal ( );
7. C ( ).
8. C ( ).
9. C ( ) ;
10.
4
- , .
1. LL(k)- (k=1 k=2) Delphi. Delphi.
2. LEX/ YACC Turbo Pascal 5.xx.
3. LEX/ YACC C.
4. LEX/ YACC C++.
5. ++.
6. .
7. JCC (Java Cmpiler Compiler). Pascal JCC.
˳.
1. .. . . - . 1981.
2. . . , . 1. . . 1978.
3. .. . . . 1975.
4. . . . . 1977.
5. . . . .. 1977.
6. .., .., .. , , -. . . 1974.
7. . . . . 1969.
|
|
8. .. . . . 1975.
9. ., ., . . . . 1980.
10. . : . . . 1979.
11. . . . . 1984.
12. . . . . 1976.
13. . . . . 1988.
14. ., ., . . . . 1979.