本文整理汇总了C#中at.jku.ssw.Coco.Symbol类的典型用法代码示例。如果您正苦于以下问题:C# Symbol类的具体用法?C# Symbol怎么用?C# Symbol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Symbol类属于at.jku.ssw.Coco命名空间,在下文中一共展示了Symbol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindAS
void FindAS(Node p, Symbol nonTerminal)
{
// find ANY sets
Node a;
while (p != null) {
if (p.typ == Node.opt || p.typ == Node.iter) {
FindAS(p.sub, nonTerminal);
a = LeadingAny(p.sub);
if (a != null) {
if (p.next == null)
Sets.Subtract(a.set, nonTerminal.follow);
else
Sets.Subtract(a.set, First(p.next));
}
} else if (p.typ == Node.alt) {
BitArray s1 = new BitArray(terminals.Count);
Node q = p;
while (q != null) {
FindAS(q.sub, nonTerminal);
a = LeadingAny(q.sub);
if (a != null)
Sets.Subtract(a.set, First(q.down).Or(s1));
else
s1.Or(First(q.sub));
q = q.down;
}
}
// Remove alternative terminals before ANY, in the following
// examples a and b must be removed from the ANY set:
// [a] ANY, or {a|b} ANY, or [a][b] ANY, or (a|) ANY, or
// A = [a]. A ANY
if (DelNode(p)) {
a = LeadingAny(p.next);
if (a != null) {
Node q = (p.typ == Node.nt) ? p.sym.graph : p.sub;
Sets.Subtract(a.set, First(q));
}
}
if (p.up) break;
p = p.next;
}
}
示例2: AttrDecl
void AttrDecl(Symbol sym)
{
if (la.kind == 29) {
Get();
sym.isAuto = true; sym.attrPos = new Position(t.pos, t.pos + 6, t.col, t.line);
} else if (la.kind == 30) {
Get();
int beg = la.pos; int col = la.col;
while (StartOf(11)) {
if (StartOf(12)) {
Get();
} else {
Get();
SemErr("bad string in attributes");
}
}
Expect(31);
if (t.pos > beg)
sym.attrPos = new Position(beg, t.pos, col, t.line);
} else if (la.kind == 32) {
Get();
int beg = la.pos; int col = la.col;
while (StartOf(13)) {
if (StartOf(14)) {
Get();
} else {
Get();
SemErr("bad string in attributes");
}
}
Expect(33);
if (t.pos > beg)
sym.attrPos = new Position(beg, t.pos, col, t.line);
} else SynErr(55);
}
示例3: GenErrorMsg
void GenErrorMsg(int errTyp, Symbol sym)
{
errorNr++;
err.Write("\t\t\tcase " + errorNr + ": s = \"");
switch (errTyp) {
case tErr:
if (sym.name[0] == '"') err.Write(tab.Escape(sym.name) + " expected");
else err.Write(sym.name + " expected");
break;
case altErr: err.Write("invalid " + sym.name); break;
case syncErr: err.Write("this symbol not expected in " + sym.name); break;
}
err.WriteLine("\"; break;");
}
示例4: ConvertToStates
public void ConvertToStates(Node p, Symbol sym)
{
curSy = sym;
if (Tab.DelGraph(p)) {
parser.SemErr("token might be empty");
return;
}
NumberNodes(p, firstState, true);
FindTrans(p, true, new BitArray(tab.nodes.Count));
if (p.typ == Node.iter) {
Step(firstState, p, new BitArray(tab.nodes.Count));
}
}
示例5: MatchLiteral
// match string against current automaton; store it either as a fixedToken or as a litToken
public void MatchLiteral(string s, Symbol sym)
{
s = tab.Unescape(s.Substring(1, s.Length-2));
int i, len = s.Length;
State state = firstState;
Action a = null;
for (i = 0; i < len; i++) { // try to match s against existing DFA
a = FindAction(state, s[i]);
if (a == null) break;
state = a.target.state;
}
// if s was not totally consumed or leads to a non-final state => make new DFA from it
if (i != len || state.endOf == null) {
state = firstState; i = 0; a = null;
dirtyDFA = true;
}
for (; i < len; i++) { // make new DFA for s[i..len-1], ML: i is either 0 or len
State to = NewState();
NewTransition(state, to, Node.chr, s[i], Node.normalTrans);
state = to;
}
Symbol matchedSym = state.endOf;
if (state.endOf == null) {
state.endOf = sym;
} else if (matchedSym.tokenKind == Symbol.fixedToken || (a != null && a.tc == Node.contextTrans)) {
// s matched a token with a fixed definition or a token with an appendix that will be cut off
parser.SemErr("tokens " + sym.name + " and " + matchedSym.name + " cannot be distinguished");
} else { // matchedSym == classToken || classLitToken
matchedSym.tokenKind = Symbol.classLitToken;
sym.tokenKind = Symbol.litToken;
}
}
示例6: Expected0
// does not look behind resolvers; only called during LL(1) test and in CheckRes
public BitArray Expected0(Node p, Symbol curSy) {
if (p.typ == Node.rslv) return new BitArray(terminals.Count);
else return Expected(p, curSy);
}
示例7: CNode
public CNode (Symbol l, Symbol r) {
left = l; right = r;
}
示例8: AttrDecl
void AttrDecl(
#line 293 "Coco.atg" //SOURCE beg=12799,len=10,col=10
Symbol sym
#line default //END SOURCE
) {
if (la.kind == 25) {
Get();
#line 294 "Coco.atg" //SOURCE beg=12850,len=36,col=36
int beg = la.pos; int col = la.col;
#line default //END SOURCE
while (StartOf(9)) {
if (StartOf(10)) {
Get();
} else {
Get();
#line 296 "Coco.atg" //SOURCE beg=12934,len=36,col=36
SemErr("bad string in attributes");
#line default //END SOURCE
}
}
Expect(26);
#line 298 "Coco.atg" //SOURCE beg=13014,len=142,col=36
if (t.pos > beg)
sym.attrPos = new Position(beg, t.pos - beg, col, GetVirtualFile(), GetVirtualLine());
#line default //END SOURCE
} else if (la.kind == 27) {
Get();
#line 300 "Coco.atg" //SOURCE beg=13195,len=36,col=36
int beg = la.pos; int col = la.col;
#line default //END SOURCE
while (StartOf(11)) {
if (StartOf(12)) {
Get();
} else {
Get();
#line 302 "Coco.atg" //SOURCE beg=13279,len=36,col=36
SemErr("bad string in attributes");
#line default //END SOURCE
}
}
Expect(28);
#line 304 "Coco.atg" //SOURCE beg=13359,len=142,col=36
if (t.pos > beg)
sym.attrPos = new Position(beg, t.pos - beg, col, GetVirtualFile(), GetVirtualLine());
#line default //END SOURCE
} else SynErr(48);
}
示例9: CheckLL1
public void CheckLL1() {
foreach (Symbol sym in nonterminals) {
curSy = sym;
CheckAlts(curSy.graph);
}
}
示例10: GenProductions
void GenProductions()
{
foreach (Symbol sym in tab.nonterminals) {
curSy = sym;
gen.Write("\tvoid {0}(", sym.name);
if (sym.isAuto)
gen.Write("Role role");
else
CopySourcePart(sym.attrPos, 0);
gen.WriteLine(") {");
if (sym.isAuto)
gen.WriteLine("\t\tvar result = new {0}(); NodeStart(result);", sym.name);
CopySourcePart(sym.semPos, 2);
GenCode(sym.graph, 2, new BitArray(tab.terminals.Count));
if (sym.isAuto)
gen.WriteLine("\t\tNodeEnd(result, role);");
gen.WriteLine("\t}"); gen.WriteLine();
}
}
示例11: AttrDecl
void AttrDecl(Symbol sym) {
if (la.kind == 24) {
Get();
int beg = la.pos; int col = la.col;
while (StartOf(9)) {
if (StartOf(10)) {
Get();
} else {
Get();
SemErr("bad string in attributes");
}
}
Expect(25);
if (t.pos > beg)
sym.attrPos = new Position(beg, t.pos, col);
} else if (la.kind == 26) {
Get();
int beg = la.pos; int col = la.col;
while (StartOf(11)) {
if (StartOf(12)) {
Get();
} else {
Get();
SemErr("bad string in attributes");
}
}
Expect(27);
if (t.pos > beg)
sym.attrPos = new Position(beg, t.pos, col);
} else SynErr(45);
}
示例12: ConvertToStates
public void ConvertToStates(Node p, Symbol sym) {
curGraph = p; curSy = sym;
if (tab.DelGraph(curGraph)) parser.SemErr("token might be empty");
NumberNodes(curGraph, firstState);
FindTrans(curGraph, true, new BitArray(tab.nodes.Count));
}
示例13: Node
public int val; //!< chr: ordinal character value
#endregion Fields
#region Constructors
public Node(int typ, Symbol sym, int line, int col)
{
this.typ = typ; this.sym = sym; this.line = line; this.col = col;
}
示例14: CompFollowSets
void CompFollowSets() {
foreach (Symbol sym in nonterminals) {
sym.follow = new BitArray(terminals.Count);
sym.nts = new BitArray(nonterminals.Count);
}
gramSy.follow[eofSy.n] = true;
visited = new BitArray(nodes.Count);
foreach (Symbol sym in nonterminals) { // get direct successors of nonterminals
curSy = sym;
CompFollow(sym.graph);
}
foreach (Symbol sym in nonterminals) { // add indirect successors to followers
visited = new BitArray(nonterminals.Count);
curSy = sym;
Complete(sym);
}
}
示例15: CheckResolvers
public void CheckResolvers() {
foreach (Symbol sym in nonterminals) {
curSy = sym;
CheckRes(curSy.graph, false);
}
}