日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

GitHub趋势榜第一:超级命令行工具Semantic,比较解析源代码

發布時間:2024/9/15 编程问答 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 GitHub趋势榜第一:超级命令行工具Semantic,比较解析源代码 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.



??新智元報道??

來源:GitHub

編輯:大明

【新智元導讀】作為開發者,天天都要與源代碼打交道,面對不同版本,不同語言的代碼進行比較、分析,理順開發流程往往是開發者的日常。近日,一款名為Semantic的源代碼分析比較工具一舉登上了GitHub趨勢榜榜首,一起來看看!


作為開發者,你是否對不同源代碼段之間的解析和比較困惑不已呢?今天的GitHub趨勢熱榜上排名第一的帖子介紹了一款多語言支持的“超級命令行工具”Semantic,或許可以解決這個令人頭疼的問題。


Semantic是一個Haskell庫,也是一個用于分析和比較源代碼的命令行工具。

?

本文將從應用功能、語言支持、開發、技術和架構、許可等五個方面介紹Semantic這款工具。


用途及功能:源代碼解析、比較、圖應用


解析(Parse)


Usage: semantic parse ([--sexpression] | [--json] | [--json-graph] | [--symbols]
| [--dot] | [--show] | [--quiet]) [FILES...]
Generate parse trees for path(s)

Available options:
--sexpression Output s-expression parse trees (default)
--json Output JSON parse trees
--json-graph Output JSON adjacency list
--symbols Output JSON symbol list
--dot Output DOT graph parse trees
--show Output using the Show instance (debug only, format
subject to change without notice)
--quiet Don't produce output, but show timing stats


比較(Diff)


Usage: semantic diff ([--sexpression] | [--json] | [--json-graph] | [--toc] |
[--dot] | [--show]) [FILE_A] [FILE_B]
Compute changes between paths

Available options:
--sexpression Output s-expression diff tree (default)
--json Output JSON diff trees
--json-graph Output JSON diff trees
--toc Output JSON table of contents diff summary
--dot Output the diff as a DOT graph
--show Output using the Show instance (debug only, format
subject to change without notice)

?

圖(Graph)


Usage: semantic graph ([--imports] | [--calls]) [--packages] ([--dot] | [--json]
| [--show]) ([--root DIR] [--exclude-dir DIR]
DIR:LANGUAGE | FILE | --language ARG (FILES... | --stdin))
Compute a graph for a directory or from a top-level entry point module

Available options:
--imports Compute an import graph (default)
--calls Compute a call graph
--packages Include a vertex for the package, with edges from it
to each module
--dot Output in DOT graph format (default)
--json Output JSON graph
--show Output using the Show instance (debug only, format
subject to change without notice)
--root DIR Root directory of project. Optional, defaults to
entry file/directory.
--exclude-dir DIR Exclude a directory (e.g. vendor)
--language ARG The language for the analysis.
--stdin Read a list of newline-separated paths to analyze
from stdin.?


多語言支持:Python、Go,Java均可使用


?

開發環境及版本要求


我們使用cabal的Nix風格的本地版本進行開發。要快速入門,可以按照下圖中的步驟:

?

git clone git@github.com:github/semantic.git cd semantic git submodule sync --recursive && git submodule update --init --recursive --force cabal new-update cabal new-build cabal new-test cabal new-run semantic -- --help


Semantic最低要求GHC 8.6.4。我們建議使用ghcup沙箱GHC版本。我們使用的版本基于StackageLTS版。目前的LTS版本是13.13。如果您愿意,也可以使用堆棧版。


技術和架構特征


從架構上看,Semantic具備以下特點:

?

  • 可以讀取blob。

  • 可以為樹形保護程序的blob生成解析樹(用于編程工具的增量解析系統)。

  • 將這些樹分配為語法的通用表示。

  • 執行分析,計算差異,或僅返回解析樹。

  • 以多種支持格式呈現輸出。

?

Semantic利用了許多有趣的算法和技術:

?

  • Myers算法(SES)如論文An O(ND)差分算法及其變化所述

  • RWS-Diff:在分層數據中靈活高效的變化檢測中描述的RWS。

  • 可以單獨打開Union和數據類型。

  • 簡要定義解釋器(Abstracting Definitional Interpreters)的實現。可擴展為基于語法術語的單點表示。


關于授權許可


Semantic基于MIT許可。


參考鏈接:

https://github.com/github/semantic

總結

以上是生活随笔為你收集整理的GitHub趋势榜第一:超级命令行工具Semantic,比较解析源代码的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。