本文整理汇总了C#中Token.GetLine方法的典型用法代码示例。如果您正苦于以下问题:C# Token.GetLine方法的具体用法?C# Token.GetLine怎么用?C# Token.GetLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Token
的用法示例。
在下文中一共展示了Token.GetLine方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckToken
public static void CheckToken(Token token, Token.Type type, string text)
{
if (token.type != type)
{
throw new Syntax.Exception(text, token.GetIndex(), token.GetLine());
}
}
示例2: 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()];
}
示例3: GetTag
public Symbol GetTag(Token t)
{
if (!this.ContainsTag(t.GetStrVal()))
{
throw new Symbols.Exception(string.Format("тэг \"{0}\" не определен", t.GetStrVal()), t.GetIndex(), t.GetLine());
}
return this.tags[t.GetStrVal()];
}
示例4: ConvertBinaryOperands
//.........这里部分代码省略.........
res.type = lop.GetType();
break;
case Token.Type.OP_AND:
case Token.Type.OP_OR:
if (!(lt.IsArifmetic() || lt is Symbols.POINTER))
{
throw new Symbols.Exception(lop, string.Format(NO_OPERATOR, op.GetStrVal()));
}
if (!(rt.IsArifmetic() || rt is Symbols.POINTER))
{
throw new Symbols.Exception(rop, string.Format(NO_OPERATOR, op.GetStrVal()));
}
uacon = UsualArithmeticConversions(lop, rop);
lop = uacon.first;
rop = uacon.last;
res.type = lop.GetType();
break;
case Token.Type.OP_ASSIGN:
if (!lop.IsLvalue())
{
throw new Symbols.Exception(lop, NOT_LVALUE);
}
if (!lt.Equals(rt))
{
rop = new Cast(rop, lt);
}
res.type = lop.GetType();
break;
case Token.Type.COMMA:
break;
case Token.Type.OP_MUL_ASSIGN:
case Token.Type.OP_DIV_ASSIGN:
case Token.Type.OP_MOD_ASSIGN:
case Token.Type.OP_PLUS_ASSIGN:
case Token.Type.OP_SUB_ASSIGN:
case Token.Type.OP_L_SHIFT_ASSIGN:
case Token.Type.OP_R_SHIFT_ASSIGN:
case Token.Type.OP_BIT_AND_ASSIGN:
case Token.Type.OP_BIT_OR_ASSIGN:
case Token.Type.OP_XOR_ASSIGN:
Token.Type tt = Token.Type.OP_STAR;
switch (op.type)
{
case Token.Type.OP_MUL_ASSIGN:
tt = Token.Type.OP_STAR;
break;
case Token.Type.OP_DIV_ASSIGN:
tt = Token.Type.OP_DIV;
break;
case Token.Type.OP_MOD_ASSIGN:
tt = Token.Type.OP_MOD;
break;
case Token.Type.OP_PLUS_ASSIGN:
tt = Token.Type.OP_PLUS;
break;
case Token.Type.OP_SUB_ASSIGN:
tt = Token.Type.OP_SUB;
break;
case Token.Type.OP_L_SHIFT_ASSIGN:
tt = Token.Type.OP_L_SHIFT;
break;
case Token.Type.OP_R_SHIFT_ASSIGN:
tt = Token.Type.OP_R_SHIFT;
break;
case Token.Type.OP_BIT_AND_ASSIGN:
tt = Token.Type.OP_BIT_AND;
break;
case Token.Type.OP_BIT_OR_ASSIGN:
tt = Token.Type.OP_BIT_OR;
break;
case Token.Type.OP_XOR_ASSIGN:
tt = Token.Type.OP_XOR;
break;
}
BinaryOperator bop = new BinaryOperator(new Token(tt));
bop.SetLeftOperand(lop);
bop.SetRightOperand(rop);
res.op = new Token(op.GetIndex(), op.GetLine(), Token.Type.OP_ASSIGN, "=");
BinaryOperator assign = new BinaryOperator(res.op);
assign.SetLeftOperand(lop);
assign.SetRightOperand(bop);
BinaryConvertResult r = ConvertBinaryOperands(lop, bop, res.op);
rop = r.right;
lop = r.left;
res.type = lop.GetType();
break;
default:
throw new System.NotImplementedException();
}
res.left = lop;
res.right = rop;
return res;
}
示例5: SetConstant
public void SetConstant(Token constant)
{
this.SetConstant(constant.GetStrVal());
this.pos = constant.GetIndex();
this.line = constant.GetLine();
}
示例6: Expression
public Expression(Token t)
{
this.pos = t.GetIndex();
this.line = t.GetLine();
}