/// <summary> /// Creates a new immutable header from the given node factory, symbol table and template table. /// </summary> /// <param name="nodeFactory"></param> /// <param name="symbolTable"></param> /// <param name="templateTable"></param> public ReaderState(LNodeFactory nodeFactory, IReadOnlyList <string> symbolTable, IReadOnlyList <NodeTemplate> templateTable) { this.NodeFactory = nodeFactory; this.SymbolTable = symbolTable; this.SymbolPool = SymbolPool.@new(); this.TemplateTable = templateTable; }
public virtual void Done() { _classBody = null; F = null; _setDeclNames = null; _currentRule = null; }
public virtual void Reset(IListSource <Token> tokens, ISourceFile file) { _tokensRoot = _tokens = tokens; _sourceFile = file; F = new LNodeFactory(file); InputPosition = 0; // reads LT(0) _missingExpr = null; }
public virtual void Reset(IListSource <Token> tokens, ISourceFile file, IParsingService hostLanguage = null) { _hostLanguage = hostLanguage ?? ParsingService.Current; _tokensRoot = _tokens = ReclassifyTokens(tokens); _sourceFile = file; F = new LNodeFactory(file); InputPosition = 0; // reads LT(0) }
protected override void Reset(IList <Token> tokens, Token eofToken, ISourceFile file, int startIndex = 0) { // Called by base class constructor Debug.Assert(eofToken.Type() == TT.EOF); base.Reset(ReclassifyTokens(tokens), eofToken, file, startIndex); _hostLanguage = ParsingService.Current; _tokensRoot = _tokenList; F = new LNodeFactory(file); }
public virtual void Reset(IListSource <Token> tokens, ISourceFile file) { CheckParam.IsNotNull("tokens", tokens); CheckParam.IsNotNull("file", file); _tokensRoot = _tokens = tokens; _sourceFile = file; F = new LNodeFactory(file); InputPosition = 0; // reads LT(0) }
protected override void Reset(IList <Token> tokens, Func <Token, Token> getEofToken, int eof, ISourceFile file, int startIndex = 0) { // Called by base class constructor Debug.Assert((TT)eof == TT.EOF); base.Reset(ReclassifyTokens(tokens), getEofToken, eof, file, startIndex); _hostLanguage = ParsingService.Default; _tokensRoot = _tokenList; F = new LNodeFactory(file); }
public bool Evaluate(IPermissionManaged resource, LNode parsedNode) { lock (IdentifierTable) { _factory = new LNodeFactory(parsedNode.Source); IdentifierTable[ResourceIdentifierName] = () => resource; var result = ResolveLiteral(parsedNode); return((bool)result.Value); } }
private IReadOnlyList <LNode> GenerateRandomNodeList(LNodeFactory Factory, Random Rand, int Depth) { var results = new LNode[(int)System.Math.Sqrt(Rand.Next(100))]; for (int i = 0; i < results.Length; i++) { results[i] = GenerateRandomNode(Factory, Rand, Depth); } return(results); }
public virtual void Reset(IListSource <Token> tokens, ISourceFile file, IParsingOptions parsingOptions) { CheckParam.IsNotNull("tokens", tokens); CheckParam.IsNotNull("file", file); _tokensRoot = _tokens = tokens; _sourceFile = file; _literalParser = parsingOptions?.LiteralParser ?? EcsLiteralHandlers.Value; F = new LNodeFactory(file); InputPosition = 0; // reads LT(0) _tentativeErrors = new TentativeState(false); }
protected override void Reset(IList <Token> list, Func <Token, Token> getEofToken, int eof, ISourceFile file, int startIndex = 0) { if (list is TokenTree) { // Token trees can come from token literals, and the user of a // token tree expects to be able to parse that tree, but this parser // expects a flat token list, so we need to flatten the tree again. list = ((TokenTree)list).Flatten(); } CheckParam.IsNotNull("file", file); base.Reset(list, getEofToken, eof, file, startIndex); F = new LNodeFactory(file); }
private LNode GenerateRandomNode(LNodeFactory Factory, Random Rand, int Depth) { int index = Rand.Next(5); switch (Depth <= 0 && index > 1 ? Rand.Next(2) : index) { case 0: return(Factory.Literal(GenerateRandomLiteral(Rand))); case 1: return(Factory.Id(GenerateRandomSymbol(Rand))); case 2: return(Factory.Attr(GenerateRandomNode(Factory, Rand, Depth - 1), GenerateRandomNode(Factory, Rand, Depth - 1))); case 3: return(Factory.Call(GenerateRandomSymbol(Rand), GenerateRandomNodeList(Factory, Rand, Depth - 1))); default: return(Factory.Call(GenerateRandomNode(Factory, Rand, Depth - 1), GenerateRandomNodeList(Factory, Rand, Depth - 1))); } }
public GenerateCodeVisitor(LLParserGenerator llpg) { LLPG = llpg; F = new LNodeFactory(llpg._sourceFile); _classBody = llpg._classBody; }
protected override void Reset(IList <Token> list, Token eofToken, ISourceFile file, int startIndex = 0) { base.Reset(list, eofToken, file, startIndex); F = new LNodeFactory(file); }
public MyParser(IList <Token> list, ISourceFile file, int startIndex = 0) : base(list, new Token((int)TT.EOF, 0, 0, null), file, startIndex) { F = new LNodeFactory(file); }
/// <summary> /// Instantiates a Flame IR encoder. /// </summary> /// <param name="codec">The codec to use for encoding.</param> /// <param name="factory">The node factory to use for creating nodes.</param> public EncoderState(IrCodec codec, LNodeFactory factory) { this.Codec = codec; this.Factory = factory; }
public ExprParser(IList <StringToken> tokens, ISourceFile file = null) : base(tokens, default(StringToken), file ?? EmptySourceFile.Unknown) { F = new LNodeFactory(SourceFile); }
public virtual void Begin(WList <LNode> classBody, ISourceFile sourceFile) { _classBody = classBody; F = new LNodeFactory(sourceFile); _setDeclNames = new Dictionary <IPGTerminalSet, Symbol>(); }
protected override void Reset(IList <Token> list, Token eofToken, ISourceFile file, int startIndex = 0) { CheckParam.IsNotNull("file", file); base.Reset(list, eofToken, file, startIndex); F = new LNodeFactory(file); }
public CodeGenHelperBase() { F = new LNodeFactory(EmptySourceFile.Unknown); ListType = F.Of(F.Id("List"), F.Id(_T)); ListInitializer = F.Call(S.New, F.Call(ListType)); }