本文整理汇总了C#中at.jku.ssw.Coco.Graph类的典型用法代码示例。如果您正苦于以下问题:C# Graph类的具体用法?C# Graph怎么用?C# Graph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Graph类属于at.jku.ssw.Coco命名空间,在下文中一共展示了Graph类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TokenTerm
static void TokenTerm(out Graph g) {
Graph g2;
TokenFactor(out g);
while (StartOf(16)) {
TokenFactor(out g2);
Graph.MakeSequence(g, g2);
}
if (la.kind == 37) {
Get();
Expect(28);
TokenExpr(out g2);
Graph.SetContextTrans(g2.l); Graph.MakeSequence(g, g2);
Expect(29);
}
}
示例2: Term
void Term(out Graph g)
{
Graph g2; Node rslv = null; g = null;
if (StartOf(19)) {
if (la.kind == 44 || la.kind == 45) {
if (la.kind == 44) {
rslv = tab.NewNode(Node.rslv, null, la.line, la.col);
Resolver(out rslv.pos);
g = new Graph(rslv);
} else {
rslv = tab.NewNode(Node.expectedConflict, null, la.line, la.col);
ExpectedConflict(out rslv.pos, out rslv.conflictSymbols);
g = new Graph(rslv);
}
}
Factor(out g2);
if (rslv != null) tab.MakeSequence(g, g2);
else g = g2;
while (StartOf(20)) {
Factor(out g2);
tab.MakeSequence(g, g2);
}
} else if (StartOf(21)) {
g = new Graph(tab.NewNode(Node.eps));
} else SynErr(58);
if (g == null) // invalid start of Term
g = new Graph(tab.NewNode(Node.eps));
}
示例3: TokenFactor
void TokenFactor(out Graph g)
{
string name; int kind; g = null;
if (la.kind == 1 || la.kind == 3 || la.kind == 5) {
Sym(out name, out kind);
if (kind == isIdent) {
CharClass c = tab.FindCharClass(name);
if (c == null) {
SemErr("undefined name");
c = tab.NewCharClass(name, new CharSet());
}
Node p = tab.NewNode(Node.clas); p.val = c.n;
g = new Graph(p);
tokenString = noString;
} else { // str
g = tab.StrToGraph(name);
if (tokenString == null) tokenString = name;
else tokenString = noString;
}
} else if (la.kind == 37) {
Get();
TokenExpr(out g);
Expect(38);
} else if (la.kind == 39) {
Get();
TokenExpr(out g);
Expect(40);
tab.MakeOption(g, t.line, 0); tokenString = noString;
} else if (la.kind == 41) {
Get();
TokenExpr(out g);
Expect(42);
tab.MakeIteration(g, t.line, 0); tokenString = noString;
} else SynErr(61);
if (g == null) // invalid start of TokenFactor
g = new Graph(tab.NewNode(Node.eps));
}
示例4: Finish
public void Finish(Graph g) {
Node p = g.r;
while (p != null) {
Node q = p.next; p.next = null;
p = q;
}
}
示例5: Expression
void Expression(out Graph g)
{
Graph g2;
Term(out g);
bool first = true;
while (WeakSeparator(34,17,18) ) {
Term(out g2);
if (first) { tab.MakeFirstAlt(g); first = false; }
tab.MakeAlternative(g, g2);
}
}
示例6: MakeAlternative
// The result will be in g1
public void MakeAlternative(Graph g1, Graph g2) {
g2.l = NewNode(Node.alt, g2.l); g2.l.line = g2.l.sub.line;
g2.l.up = true;
g2.r.up = true;
Node p = g1.l; while (p.down != null) p = p.down;
p.down = g2.l;
p = g1.r; while (p.next != null) p = p.next;
// append alternative to g1 end list
p.next = g2.l;
// append g2 end list to g1 end list
g2.l.next = g2.r;
}
示例7: MakeIteration
public void MakeIteration(Graph g) {
g.l = NewNode(Node.iter, g.l);
g.r.up = true;
Node p = g.r;
g.r = g.l;
while (p != null) {
Node q = p.next; p.next = g.l;
p = q;
}
}
示例8: MakeIteration
public void MakeIteration(Graph g, int line, int col)
{
g.l = NewNode(Node.iter, g.l);
g.l.line = line; g.l.col = col;
g.r.up = true;
Node p = g.r;
g.r = g.l;
while (p != null) {
Node q = p.next; p.next = g.l;
p = q;
}
}
示例9: MakeOption
public void MakeOption(Graph g, int line, int col)
{
g.l = NewNode(Node.opt, g.l);
g.l.line = line; g.l.col = col;
g.r.up = true;
g.l.next = g.r;
g.r = g.l;
}
示例10: MakeOption
public static void MakeOption(Graph g) {
g.l = new Node(Node.opt, g.l);
g.l.next = g.r;
g.r = g.l;
}
示例11: StrToGraph
public static Graph StrToGraph(string str) {
string s = DFA.Unescape(str.Substring(1, str.Length-2));
if (s.IndexOf('\0') >= 0) Parser.SemErr("\\0 not allowed here. Used as eof character");
if (s.Length == 0) Parser.SemErr("empty token not allowed");
Graph g = new Graph();
g.r = dummyNode;
for (int i = 0; i < s.Length; i++) {
Node p = new Node(Node.chr, (int)s[i], 0);
g.r.next = p; g.r = p;
}
g.l = dummyNode.next; dummyNode.next = null;
return g;
}
示例12: MakeAlternative
public static void MakeAlternative(Graph g1, Graph g2) {
g2.l = new Node(Node.alt, g2.l); g2.l.line = g2.l.sub.line;
Node p = g1.l; while (p.down != null) p = p.down;
p.down = g2.l;
p = g1.r; while (p.next != null) p = p.next;
p.next = g2.r;
}
示例13: MakeFirstAlt
public static void MakeFirstAlt(Graph g) {
g.l = new Node(Node.alt, g.l); g.l.line = g.l.sub.line; /* AW 2002-03-07 make line available for error handling */
g.l.next = g.r;
g.r = g.l;
}
示例14: TokenFactor
static void TokenFactor(out Graph g) {
string name; int kind;
g = new Graph();
if (la.kind == 1 || la.kind == 3 || la.kind == 5) {
Sym(out name, out kind);
if (kind == id) {
CharClass c = CharClass.Find(name);
if (c == null) {
SemErr("undefined name");
c = new CharClass(name, new BitArray(CharClass.charSetSize));
}
Node p = new Node(Node.clas, null, 0); p.val = c.n;
g = new Graph(p);
} else g = Graph.StrToGraph(name); // str
} else if (la.kind == 28) {
Get();
TokenExpr(out g);
Expect(29);
} else if (la.kind == 30) {
Get();
TokenExpr(out g);
Expect(31);
Graph.MakeOption(g);
} else if (la.kind == 32) {
Get();
TokenExpr(out g);
Expect(33);
Graph.MakeIteration(g);
} else SynErr(54);
}
示例15: Factor
void Factor(
#line 341 "Coco.atg" //SOURCE beg=14902,len=11,col=8
out Graph g
#line default //END SOURCE
) {
#line 341 "Coco.atg" //SOURCE beg=14930,len=137,col=36
string name; int kind; Position pos; bool weak = false;
g = null;
#line default //END SOURCE
switch (la.kind) {
case _ident: case _string: case _char: case 30: {
if (la.kind == 30) {
Get();
#line 345 "Coco.atg" //SOURCE beg=15109,len=13,col=36
weak = true;
#line default //END SOURCE
}
Sym(
#line 347 "Coco.atg" //SOURCE beg=15137,len=18,col=7
out name, out kind
#line default //END SOURCE
);
#line 347 "Coco.atg" //SOURCE beg=15166,len=1542,col=36
Symbol sym = tab.FindSym(name);
if (sym == null && kind == str)
sym = tab.literals[name] as Symbol;
bool undef = sym == null;
if (undef) {
if (kind == id)
sym = tab.NewSym(Node.nt, name, 0); // forward nt
else if (genScanner) {
sym = tab.NewSym(Node.t, name, t.line);
dfa.MatchLiteral(sym.name, sym);
} else { // undefined string in production
SemErr("undefined string in production");
sym = tab.eofSy; // dummy
}
}
int typ = sym.typ;
if (typ != Node.t && typ != Node.nt)
SemErr("this symbol kind is not allowed in a production");
if (weak)
if (typ == Node.t) typ = Node.wt;
else SemErr("only terminals may be weak");
Node p = tab.NewNode(typ, sym, t.line);
g = new Graph(p);
#line default //END SOURCE
if (la.kind == 25 || la.kind == 27) {
Attribs(
#line 371 "Coco.atg" //SOURCE beg=16724,len=1,col=13
p
#line default //END SOURCE
);
#line 371 "Coco.atg" //SOURCE beg=16747,len=62,col=36
if (kind != id) SemErr("a literal must not have attributes");
#line default //END SOURCE
}
#line 372 "Coco.atg" //SOURCE beg=16848,len=312,col=36
if (undef)
sym.attrPos = p.pos; // dummy
else if ((p.pos == null) != (sym.attrPos == null))
SemErr("attribute mismatch between declaration and use of this symbol");
#line default //END SOURCE
break;
}
case 31: {
Get();
Expression(
#line 377 "Coco.atg" //SOURCE beg=17181,len=5,col=18
out g
#line default //END SOURCE
);
Expect(32);
break;
}
case 33: {
Get();
Expression(
#line 378 "Coco.atg" //SOURCE beg=17210,len=5,col=18
out g
#line default //END SOURCE
);
Expect(34);
#line 378 "Coco.atg" //SOURCE beg=17228,len=19,col=36
tab.MakeOption(g);
#line default //END SOURCE
break;
}
case 35: {
Get();
Expression(
//.........这里部分代码省略.........