Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在c#中解析javascript以分离代码文件?_Javascript_C#_Asp.net - Fatal编程技术网

如何在c#中解析javascript以分离代码文件?

如何在c#中解析javascript以分离代码文件?,javascript,c#,asp.net,Javascript,C#,Asp.net,下面是我要分析的示例脚本文件: <script> module.exports = function() { internals: function() { return { key: "value", anotherKey: "some other value" } }, fruit: { apples: function() { return "Don't like

下面是我要分析的示例脚本文件:

<script>
  module.exports = function() {
    internals: function() {
      return {
        key: "value",
        anotherKey: "some other value"
      }
    },

    fruit: {
      apples: function() {
        return "Don't like them";
      },
      bananas: function() {
        return "Yuck";
      } 
    },

    drinks: {
      water: function(ice) {
        return ice ? "water with ice" : "just water";
      }
    }
  }
</script>
水果
将包含:

Key: "key" Value: "value"
Key: "anotherKey" Value: "some other value"
Key: "apples" Value: "function() {\n return "Don't like them"; \n}
Key: "bananas" Value: "function() {\n return "Yuck"; \n}
等等

但仍然能够解析:

water(ice) {
  return ice ? "water with ice" : "just water";
}
我基本上想抽象所有的内部结构、水果和饮料,这样我就可以迭代它们,然后写回一个文件。。。因此,我可能会这样做:

foreach(var f in fruit) {
  // etc.
}
这样我就可以按原样重新创建脚本文件


我希望能够解析它,而不考虑箭头函数和更新的
js
语法。我只想了解每一部分的内容。希望这是有意义的。

你自己做这件事是我的专长。你看过预构建的解析器吗?看过。他们中的大多数都是关于执行实际的代码。。。net等。
foreach(var f in fruit) {
  // etc.
}