本文整理汇总了C#中Token.GetStrVal方法的典型用法代码示例。如果您正苦于以下问题:C# Token.GetStrVal方法的具体用法?C# Token.GetStrVal怎么用?C# Token.GetStrVal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Token
的用法示例。
在下文中一共展示了Token.GetStrVal方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSymbol
public Symbol GetSymbol(Token t, System.Type symbol_type)
{
if (!this.ContainsSymbol(t.GetStrVal(), symbol_type))
{
string error = "";
if (symbol_type == typeof(Type))
{
error = string.Format("тип \"{0}\" не определен", t.GetStrVal());
}
else if (symbol_type == typeof(Var))
{
error = string.Format("переменная \"{0}\" не определена", t.GetStrVal());
}
throw new Symbols.Exception(error, t.GetIndex(), t.GetLine());
}
return this.symbols[t.GetStrVal()];
}
示例2: GetTag
public Symbol GetTag(Token t)
{
Table itr = this.current;
while (itr != null)
{
if (itr.ContainsTag(t.GetStrVal()))
{
return itr.GetTag(t);
}
itr = itr.parent;
}
return this.root.GetTag(t);
}
示例3: ConvertBinaryOperands
//.........这里部分代码省略.........
}
if (lt.IsArifmetic() || rt.IsArifmetic())
{
if (!lt.IsArifmetic())
{
throw new Symbols.Exception(lop, NOT_ARITHMETICAL);
}
if (!rt.IsArifmetic())
{
throw new Symbols.Exception(rop, NOT_ARITHMETICAL);
}
uacon = UsualArithmeticConversions(lop, rop);
lop = uacon.first;
rop = uacon.last;
res.type = lop.GetType();
break;
}
if (lt is Symbols.Func ||
(lt is Symbols.POINTER && ((Symbols.POINTER)lt).GetRefType() is Symbols.Func))
{
throw new Symbols.Exception(lop, NOT_COMPLETE_TYPE);
}
if (rt is Symbols.Func ||
(rt is Symbols.POINTER && ((Symbols.POINTER)rt).GetRefType() is Symbols.Func))
{
throw new Symbols.Exception(rop, NOT_COMPLETE_TYPE);
}
throw new Symbols.Exception(lop, string.Format(NO_OPERATOR, op.GetStrVal()));
case Token.Type.OP_L_SHIFT:
case Token.Type.OP_R_SHIFT:
case Token.Type.OP_BIT_AND:
case Token.Type.OP_BIT_OR:
case Token.Type.OP_XOR:
if (!lt.IsInteger())
{
throw new Symbols.Exception(lop, NOT_ARITHMETICAL);
}
if (!rt.IsInteger())
{
throw new Symbols.Exception(rop, NOT_ARITHMETICAL);
}
uacon = UsualArithmeticConversions(lop, rop);
lop = uacon.first;
rop = uacon.last;
res.type = lop.GetType();
break;
case Token.Type.OP_MORE:
case Token.Type.OP_LESS:
case Token.Type.OP_LESS_OR_EQUAL:
case Token.Type.OP_MORE_OR_EQUAL:
case Token.Type.OP_EQUAL:
case Token.Type.OP_NOT_EQUAL:
uacon = UsualArithmeticConversions(lop, rop);
lop = uacon.first;
rop = uacon.last;
res.type = lop.GetType();
break;
示例4: ConvertUnaryOperand
public static UnaryConvertResult ConvertUnaryOperand(Expression operand, Token op)
{
UnaryConvertResult res = new UnaryConvertResult();
Symbols.Type t = operand.GetType();
switch (op.type)
{
case Token.Type.OP_INC:
case Token.Type.OP_DEC:
Token.Type tt = op.type == Token.Type.OP_DEC ?
Token.Type.OP_SUB_ASSIGN : Token.Type.OP_PLUS_ASSIGN;
BinaryOperator bop = new BinaryOperator(new Token(tt));
bop.SetLeftOperand(operand);
bop.SetRightOperand(new Const("1", new Symbols.INT()));
res.type = bop.GetType();
break;
case Token.Type.OP_BIT_AND:
if (!(operand.IsLvalue() || operand.GetType() is Symbols.Func))
{
throw new Symbols.Exception(operand, NOT_LVALUE_OR_FUNC);
}
res.type = new Symbols.POINTER(operand.GetType());
break;
case Token.Type.OP_STAR:
res.lvalue = true;
if (!(t is Symbols.POINTER || t is Symbols.Func))
{
throw new Symbols.Exception(operand, NOT_POINTER);
}
if (t is Symbols.Func)
{
res.type = t;
}
else
{
res.type = ((Symbols.RefType)t).GetRefType();
}
break;
case Token.Type.OP_PLUS:
case Token.Type.OP_SUB:
if (!t.IsArifmetic())
{
throw new Symbols.Exception(operand, NOT_ARITHMETICAL);
}
res.type = t;
break;
case Token.Type.OP_TILDE:
if (!t.IsInteger())
{
throw new Symbols.Exception(operand, NOT_INTEGER);
}
res.type = t;
break;
case Token.Type.OP_NOT:
if (!(t.IsArifmetic() || t is Symbols.Func || t is Symbols.POINTER))
{
throw new Symbols.Exception(operand, string.Format(NO_OPERATOR, op.GetStrVal()));
}
res.type = new Symbols.INT();
break;
case Token.Type.KW_SIZEOF:
res.type = new Symbols.INT();
break;
case Token.Type.OP_DOT:
default:
throw new System.NotImplementedException();
}
res.operand = operand;
return res;
}
示例5: SetConstant
public void SetConstant(Token constant)
{
this.SetConstant(constant.GetStrVal());
this.pos = constant.GetIndex();
this.line = constant.GetLine();
}
示例6: Symbol
public Symbol(Token t)
{
this.index = t.pos;
this.line = t.line;
this.SetName(t.GetStrVal());
}