private void ProcessValidField(ReaderContext context) { var fieldData = context.FieldData; // Remove the tokens associated with this field from the main token buffer, as we don't want it to be outputted. _tokenBuffer.RemoveTokensSince(fieldData.SourceStart); // Parse the macro ParseTree parseTree; try { parseTree = DocMacroGrammar.ParseMacro(fieldData.Macro); } catch (ParseException ex) { context.WriteError(ex.ShortMessage); return; } // Find the instruction node // TODO - handle multiple instructions var instructionSetNode = parseTree.Root; AssertTerm(instructionSetNode, DocTerms.InstructionSet); AssertChildren(instructionSetNode, 1); var instructionNode = instructionSetNode.ChildNodes[0]; // And process it ProcessInstruction(context, instructionNode); }
/// <summary> /// Parse a query and return the first instruction. /// </summary> private ParseTreeNode RunSingleTest(string script) { var result = DocMacroGrammar.ParseMacro(script); var root = CheckTerm(result.Root, DocTerms.InstructionSet); var instruction = root.ChildNodes[0]; return(instruction); }