static public ParserNode Parse(string data, ParserType parserType, bool strict) { switch (parserType) { case ParserType.Balanced: return(BalancedVisitor.Parse(data, strict)); case ParserType.Columns: return(ColumnsVisitor.Parse(data, strict)); case ParserType.CSharp: return(CSharpVisitor.Parse(data, strict)); case ParserType.CSV: return(CSVVisitor.Parse(data, strict)); case ParserType.ExactColumns: return(ExactColumnsVisitor.Parse(data, strict)); case ParserType.HTML: return(HTMLVisitor.Parse(data, strict)); case ParserType.JSON: return(JSONVisitor.Parse(data, strict)); case ParserType.SQL: return(SQLVisitor.Parse(data, strict)); case ParserType.TSV: return(TSVVisitor.Parse(data, strict)); case ParserType.XML: return(XMLVisitor.Parse(data, strict)); default: throw new ArgumentException("Unable to parse this type"); } }
static public string Reformat(ParserNode node, string input, ParserType parserType) { switch (parserType) { case ParserType.HTML: return(HTMLVisitor.Format(node, input)); case ParserType.JSON: return(JSONVisitor.Format(node, input)); case ParserType.XML: return(XMLVisitor.Format(node, input)); default: throw new Exception("Unable to reformat this type"); } }
public IHttpActionResult Post([FromBody]string source) { if (source == null) { return BadRequest(); } Parser parser = new Parser(source); parser.parse(); CFGVisitor cfgv = new CFGVisitor(parser.ast); ScopeVisitor sv = new ScopeVisitor(parser.ast); DDGVisitor ddgv = new DDGVisitor(parser.ast); JSONVisitor jsonv = new JSONVisitor(parser.ast); return Ok(jsonv.graph); }