本文整理汇总了C#中Microsoft.Scripting.SourceLocation类的典型用法代码示例。如果您正苦于以下问题:C# SourceLocation类的具体用法?C# SourceLocation怎么用?C# SourceLocation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SourceLocation类属于Microsoft.Scripting命名空间,在下文中一共展示了SourceLocation类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ReadToken
public override TokenInfo ReadToken()
{
Token token = tokenizer.GetNext ();
SourceLocation location = new SourceLocation(token.StartPosition,token.StartLine,token.StartColumn);
SS.SourceSpan span = new SS.SourceSpan (ConvertToSSSrcLocation(location), ConvertToSSSrcLocation(tokenizer.Position));
TokenTriggers trigger = GetTrigger(token.Kind);
TokenCategory category = GetCategory (token.Kind);
return new TokenInfo (span, category, trigger);
}
开发者ID:alesliehughes,项目名称:olive,代码行数:9,代码来源:JSTokenizerService.cs
示例2: ValidateLocations
private static void ValidateLocations(SourceLocation start, SourceLocation end) {
if (start.IsValid && end.IsValid) {
if (start > end) {
throw new ArgumentException("Start and End must be well ordered");
}
} else {
if (start.IsValid || end.IsValid) {
throw new ArgumentException("Start and End must both be valid or both invalid");
}
}
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:11,代码来源:SourceSpan.cs
示例3: HappySourceLocation
public HappySourceLocation(SourceUnit unit, SourceLocation start, SourceLocation end)
{
ContractUtils.RequiresNotNull(unit, "unit");
ContractUtils.RequiresNotNull(start, "start");
ContractUtils.RequiresNotNull(end, "end");
//ContractUtils.Requires(isBefore(start, end), "start and end must be well ordered");
if(!isBefore(start, end))
throw new ApplicationException("start and end must be well ordered");
this.Unit = unit;
this.Span = new SourceSpan(start, end);
}
开发者ID:dlurton,项目名称:Happy,代码行数:11,代码来源:HappySourceLocation.cs
示例4: Init
public void Init()
{
mockCompiler = new MockPythonCompiler();
compiler = new DummyPythonCompilerTask(mockCompiler, @"C:\Projects\MyProject");
compiler.TargetType = "Exe";
compiler.OutputAssembly = "test.exe";
TaskItem sourceFile = new TaskItem(@"D:\Projects\MyProject\PythonApp.Program.py");
compiler.Sources = new ITaskItem[] {sourceFile};
SourceUnit source = DefaultContext.DefaultPythonContext.CreateSourceUnit(NullTextContentProvider.Null, @"PythonApp\Program", SourceCodeKind.InteractiveCode);
SourceLocation start = new SourceLocation(0, 1, 1);
SourceLocation end = new SourceLocation(0, 2, 3);
SourceSpan span = new SourceSpan(start, end);
SyntaxErrorException ex = new SyntaxErrorException("Error", source, span, 1000, Severity.FatalError);
mockCompiler.ThrowExceptionAtCompile = ex;
success = compiler.Execute();
}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:20,代码来源:SyntaxErrorFileNameWithDotCharTestFixture.cs
示例5: Output
public Token Output(Symbol symbol)
{
var loc = new SourceLocation(index, Line, Column);
return new Token(symbol, new SourceSpan(loc, loc));
}
开发者ID:fgretief,项目名称:IronLua,代码行数:5,代码来源:Input.cs
示例6: TransformMaybeSingleLineSuite
public MSAst.Expression TransformMaybeSingleLineSuite(Statement body, SourceLocation prevStart) {
MSAst.Expression res;
if (body.Start.Line == prevStart.Line) {
// avoid creating and throwing away as much line number goo as we can...
res = body.Transform(this);
} else {
res = Transform(body);
}
MSAst.BlockExpression block = res as MSAst.BlockExpression;
if (block != null && block.Expressions.Count > 0) {
MSAst.DebugInfoExpression dbgInfo = block.Expressions[0] as MSAst.DebugInfoExpression;
// body on the same line as an if, don't generate a 2nd sequence point
if (dbgInfo != null && dbgInfo.StartLine == prevStart.Line) {
// we remove the debug info based upon how it's generated in DebugStatement.AddDebugInfo which is
// the helper method which adds the debug info.
if (block.Type == typeof(void)) {
Debug.Assert(block.Expressions.Count == 3);
Debug.Assert(block.Expressions[2] is MSAst.DebugInfoExpression && ((MSAst.DebugInfoExpression)block.Expressions[2]).IsClear);
res = block.Expressions[1];
} else {
Debug.Assert(block.Expressions.Count == 4);
Debug.Assert(block.Expressions[3] is MSAst.DebugInfoExpression && ((MSAst.DebugInfoExpression)block.Expressions[2]).IsClear);
Debug.Assert(block.Expressions[1] is MSAst.BinaryExpression && ((MSAst.BinaryExpression)block.Expressions[2]).NodeType == MSAst.ExpressionType.Assign);
res = ((MSAst.BinaryExpression)block.Expressions[1]).Right;
}
}
}
if (res.Type != typeof(void)) {
res = AstUtils.Void(res);
}
return res;
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:35,代码来源:AstGenerator.cs
示例7: TransformLoopBody
internal MSAst.Expression TransformLoopBody(Statement body, SourceLocation headerStart, out LabelTarget breakLabel, out LabelTarget continueLabel) {
// Save state
bool savedInFinally = _inFinally;
LabelTarget savedBreakLabel = _breakLabel;
LabelTarget savedContinueLabel = _continueLabel;
int loopId = ++_loopOrFinallyId;
LoopOrFinallyIds.Add(loopId, false);
_inFinally = false;
breakLabel = _breakLabel = Ast.Label("break");
continueLabel = _continueLabel = Ast.Label("continue");
MSAst.Expression result;
try {
result = TransformMaybeSingleLineSuite(body, headerStart);
} finally {
_inFinally = savedInFinally;
_breakLabel = savedBreakLabel;
_continueLabel = savedContinueLabel;
LoopOrFinallyIds.Remove(loopId);
}
return result;
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:23,代码来源:AstGenerator.cs
示例8: FinishSlice
private Expression FinishSlice(Expression e0, SourceLocation start) {
Expression e1 = null;
Expression e2 = null;
bool stepProvided = false;
switch (PeekToken().Kind) {
case TokenKind.Comma:
case TokenKind.RightBracket:
break;
case TokenKind.Colon:
// x[?::?]
stepProvided = true;
NextToken();
e2 = ParseSliceEnd();
break;
default:
// x[?:val:?]
e1 = ParseExpression();
if (MaybeEat(TokenKind.Colon)) {
stepProvided = true;
e2 = ParseSliceEnd();
}
break;
}
SliceExpression ret = new SliceExpression(e0, e1, e2, stepProvided);
ret.SetLoc(start, GetEnd());
return ret;
}
开发者ID:techarch,项目名称:ironruby,代码行数:28,代码来源:Parser.cs
示例9: ExpectMatch
Token ExpectMatch(Symbol right, Symbol left, SourceLocation leftStart)
{
if (Current.Symbol != right)
{
if (Current.Line == leftStart.Line)
{
throw ReportSyntaxErrorNear("'{0}' expected",
right.ToTokenString());
}
throw ReportSyntaxErrorNear("'{0}' expected (to close '{1}' at line {2})",
right.ToTokenString(),
left.ToTokenString(),
leftStart.Line);
}
return Consume();
}
开发者ID:fgretief,项目名称:IronLua,代码行数:17,代码来源:Parser.cs
示例10: SetLoc
public void SetLoc(SourceLocation start, SourceLocation header, SourceLocation end) {
Start = start;
_header = header;
End = end;
}
开发者ID:mstram,项目名称:ironruby,代码行数:5,代码来源:WhileStatement.cs
示例11: PythonProperty
public PythonProperty(IClass declaringType, string name, SourceLocation location)
: base(declaringType, name)
{
GetPropertyRegion(location);
declaringType.Properties.Add(this);
}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:6,代码来源:PythonProperty.cs
示例12: Initialize
public override void Initialize(object state, TextReader/*!*/ reader, SourceUnit sourceUnit, SourceLocation initialLocation) {
ContractUtils.RequiresNotNull(reader, "reader");
_sourceUnit = sourceUnit;
_input = reader;
_initialLocation = initialLocation;
_currentLine = _initialLocation.Line;
_currentLineIndex = _initialLocation.Index;
_tokenSpan = new SourceSpan(initialLocation, initialLocation);
SetState(LexicalState.EXPR_BEG);
_tokenValue = new TokenValue();
_eofReached = false;
_unterminatedToken = false;
DumpBeginningOfUnit();
}
开发者ID:bclubb,项目名称:ironruby,代码行数:19,代码来源:Tokenizer.cs
示例13: SourceSpan
/// <summary>
/// Constructs a new span with a specific start and end location.
/// </summary>
/// <param name="start">The beginning of the span.</param>
/// <param name="end">The end of the span.</param>
public SourceSpan(SourceLocation start, SourceLocation end) {
ValidateLocations(start, end);
this._start = start;
this._end = end;
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:10,代码来源:SourceSpan.cs
示例14: GetBodyRegion
/// <summary>
/// Gets the body region for a class or a method.
/// </summary>
/// <remarks>
/// Note that SharpDevelop line numbers are zero based but the
/// DomRegion values are one based. IronPython columns and lines are one based.
/// </remarks>
/// <param name="body">The body statement.</param>
/// <param name="header">The location of the header. This gives the end location for the
/// method or class definition up to the colon.</param>
public static DomRegion GetBodyRegion(Statement body, SourceLocation header)
{
int columnAfterColonCharacter = header.Column + 1;
return new DomRegion(header.Line, header.Column + 1, body.End.Line, body.End.Column);
}
开发者ID:siegfriedpammer,项目名称:SharpDevelop,代码行数:15,代码来源:PythonMethodOrClassBodyRegion.cs
示例15: OutputBuffer
public Token OutputBuffer(Symbol symbol)
{
var loc1 = new SourceLocation(storedIndex, storedLine, storedColumn);
var loc2 = new SourceLocation(index, Line, Column);
return new Token(symbol, new SourceSpan(loc1, loc2), buffer.ToString());
}
开发者ID:fgretief,项目名称:IronLua,代码行数:6,代码来源:Input.cs
示例16: GetPropertyRegion
void GetPropertyRegion(SourceLocation location)
{
int line = location.Line;
int column = location.Column;
Region = new DomRegion(line, column, line, column);
}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:6,代码来源:PythonProperty.cs
示例17: AddDebugInfo
internal Expression/*!*/ AddDebugInfo(Expression/*!*/ expression, SourceLocation start, SourceLocation end)
{
//if (TotemContext.PythonOptions.GCStress != null)
//{
// expression = Ast.Block(
// Ast.Call(
// typeof(GC).GetMethod("Collect", new[] { typeof(int) }),
// Ast.Constant(PyContext.PythonOptions.GCStress.Value)
// ),
// expression
// );
//}
return Utils.AddDebugInfo(expression, Document, start, end);
}
开发者ID:Alxandr,项目名称:IronTotem-3.0,代码行数:15,代码来源:ScopeStmt.cs
示例18: ReportSyntaxError
internal void ReportSyntaxError(SourceLocation start, SourceLocation end, string message, int errorCode) {
// save the first one, the next error codes may be induced errors:
if (_errorCode == 0) {
_errorCode = errorCode;
}
_errors.Add(_sourceUnit, message, new SourceSpan(start, end), errorCode, Severity.FatalError);
}
开发者ID:techarch,项目名称:ironruby,代码行数:7,代码来源:Parser.cs
示例19: AddDebugInfo
internal MSAst.Expression/*!*/ AddDebugInfo(MSAst.Expression/*!*/ expression, SourceLocation start, SourceLocation end) {
return Utils.AddDebugInfo(expression, _document, start, end);
}
开发者ID:tnachen,项目名称:ironruby,代码行数:3,代码来源:AstGenerator.cs
示例20: AddError
public void AddError(string message, SourceLocation start, SourceLocation end, Severity severity, int errorCode)
{
_errors.Add(SourceUnit, message, new SourceSpan(start, end), errorCode, severity);
}
开发者ID:robertlj,项目名称:IronScheme,代码行数:4,代码来源:CompilerContext.cs
注:本文中的Microsoft.Scripting.SourceLocation类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论