c# - .NET TypeScript parser to AST -


i'm looking typescript parser produces ast (abstract syntax tree) typescript code, code created visual studio.

i think visual studio must have such parser since uses code intelligence.

i know can compile ts js , use jint produce ast, it's no me. need strict relation between ast nodes , original lines in ts source.

is there way put hands on vs / windows dll ast, or maybe there library providing such functionality? i've done research , found incomplete , limited.

there microsoft typescript compiler written in typescript, how use c#? fast enough parse edited code in real-time?

for sake of clarification: need parser written in c# or in c++ c# bindings. or... ok, written in language, accessible level of c# code. i'm afraid i'll have write own parser, don't want reinvent wheel.

the point want visualize code. not want code executed c#. want see structure , has accurate, no missing elements.

most parsers / compilers i've seen had thousands loc written in solely purpose of executing scripts. covered limited subset of language syntax. need opposite. no running, full syntax. without control structures, irrelevant visualization. need ast function declarations , object definition declarations.

i know there parser / compiler of every imaginable language written in javascript, there written in c#?

i'm looking typescript parser produces ast (abstract syntax tree) typescript code, code created visual studio.

checkout section : http://basarat.gitbooks.io/typescript/content/docs/compiler/parser.html

here code sample print out ast:

import * ts "ntypescript";  function printallchildren(node: ts.node, depth = 0) {     console.log(new array(depth + 1).join('----'), ts.syntaxkindtoname(node.kind), node.pos, node.end);     depth++;     node.getchildren().foreach(c=> printallchildren(c, depth)); }  var sourcecode = ` var foo = 123; `.trim();  var sourcefile = ts.createsourcefile('foo.ts', sourcecode, ts.scripttarget.es5, true); printallchildren(sourcefile); 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -