本文整理汇总了C#中SourceUnit.GetCode方法的典型用法代码示例。如果您正苦于以下问题:C# SourceUnit.GetCode方法的具体用法?C# SourceUnit.GetCode怎么用?C# SourceUnit.GetCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SourceUnit
的用法示例。
在下文中一共展示了SourceUnit.GetCode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
private SourceUnitTree Parse(SourceUnit sourceUnit, bool allowSingle, out bool isExpression)
{
isExpression = false;
IronyParser parser = new IronyParser(allowSingle ? singleStatement : fullGrammar);
parser.Context.Mode = ParseMode.CommandLine;
scopes = new Stack<LexicalScopeBuilder>();
EnterTopLevelScope();
try
{
var parsedScript = parser.Parse(sourceUnit.GetCode());
if (parsedScript.HasErrors())
{
sourceUnit.CodeProperties = ScriptCodeParseResult.Invalid;
return null;
}
if (sourceUnit.Kind == SourceCodeKind.InteractiveCode && parser.Context.Status == ParserStatus.AcceptedPartial)
{
sourceUnit.CodeProperties = ScriptCodeParseResult.IncompleteStatement;
return null;
}
sourceUnit.CodeProperties = ScriptCodeParseResult.Complete;
return BuildSourceTree(parsedScript.Root, sourceUnit, allowSingle, out isExpression);
}
catch (Exception e)
{
throw;
}
finally
{
LeaveScope();
}
}
示例2: SyntaxErrorException
public SyntaxErrorException(string message, SourceUnit sourceUnit, SourceSpan span, int errorCode, Severity severity)
: base(message) {
ContractUtils.RequiresNotNull(message, "message");
_span = span;
_severity = severity;
_errorCode = errorCode;
if (sourceUnit != null) {
_sourcePath = sourceUnit.Path;
try {
_sourceCode = sourceUnit.GetCode();
_sourceLine = sourceUnit.GetCodeLine(Line);
} catch (System.IO.IOException) {
// could not get source code.
}
}
}
示例3: CompileSourceCode
public override ScriptCode CompileSourceCode(SourceUnit sourceUnit, CompilerOptions options, ErrorSink errorSink)
{
SilverLexer lexer = new SilverLexer("source", sourceUnit.GetCode());
CommonTokenStream stream = new CommonTokenStream(lexer.Queue);
SilverParser parser = new SilverParser(stream);
lexer.SetLines (parser);
parser.SourceUnit = sourceUnit;
var res = parser.program();
if (res != null) {
Expression mainBlock = AstExpression.Block (res);
return new SilverScriptCode(mainBlock, sourceUnit);
} else {
throw new SyntaxErrorException("Syntax error", sourceUnit, SourceSpan.None, 0, Severity.Error);
}
}
示例4: ClojureParser
public ClojureParser(SourceUnit src)
{
_source = src;
_text = src.GetCode();
}
示例5: CompileSourceCode
public ScriptCode CompileSourceCode(SourceUnit sourceUnit, CompilerOptions options, ErrorSink errorSink)
{
Contract.RequiresNotNull(sourceUnit, "sourceUnit");
if (options == null) options = GetCompilerOptions();
if (errorSink == null) errorSink = Engine.GetCompilerErrorSink();
CompilerContext context = new CompilerContext(sourceUnit, options, errorSink);
CodeBlock block = ParseSourceCode(context);
if (block == null) {
throw new SyntaxErrorException("invalid syntax|" + sourceUnit.GetCode().Trim());
}
//DumpBlock(block, sourceUnit.Id);
AnalyzeBlock(block);
DumpBlock(block, sourceUnit.Id);
// TODO: ParseSourceCode can update CompilerContext.Options
return new ScriptCode(block, Engine.GetLanguageContext(context.Options), context);
}