c2compiler the c2 programming language开源项目

我要开发同款
匿名用户2021年11月08日
43阅读
开发技术C/C++
所属分类开发工具、编译器
授权协议Apache-2.0 License

作品详情

C2Compiler

PleaseseeC2Lang.orgformoreinfoaboutC2!

TheC2projectattemptstocreateanewlanguage,stronglybasedonC.Inanutshell,themaindifferenceswithCare:

nomoreheaderfiles(toomuchtyping)noincludespackages(neededifwecan'thaveincludes)compiledpertarget(notperfile)morelogicalkeywords(public/localreplacesstatic)integratedbuildsystem

BelowaretheinstructionsforbuildingandusingtheC2Compiler.

Havefun!(andcode..)

Generic

C2isbasedonLLVM7.0andsomepartsofClang7.0.ThedesignofC2C'sParserandASTBuilderclassesareheavilybasedonclang'sParserandSemaclass,soherebymythankstotheClangfolks!

Whatneedstobedone

Ashortlistofopenitems(thefulllistwouldprobablyfill-upGitHub)withtheirpriority:

[high]c2c:parsefullsyntaxintoAST(ALMOSTDONE)[high]c2c:generateIRcodeformoreASTelements[medium]tool:creategraphicalrefactortool(c2reto)(INPROGRESS)[medium]c2c:tabcompletionontargetsinrecipe/cmdlineargs[medium]tool:createc-parserforparsingCheaders.[medium]tool:createc2format-astyleforC2.[low]tool:c2grep-greponlyfilesinrecipeInstallation

ReadtheinstallationdocumentforinstallationonLinuxorOSX.ForWindowsinstallation,seewindowsinstallationdocument.

UsingtheC2compiler

Bydefault,c2cwillonlyparseandanalysethetargets.GeneratingC-codeshouldworkonallexamples,butgeneratingLLVM'sIRcodeisworkinprogress.Intheexamplesdirectory:(oradd-dexamples/)

c2cmultic2chelloc2cpuzzlec2c-Iworking_ir

It'salsopossibletomanuallycompileasingle.c2filewithoutarecipefilewith:

c2c-f<file.c2>

TogenerateANSI-Ccode,use:

c2c-C<target>

TheC2compilerisabletogenerateapackagedependencyfileindotformat.Thisfilecanbeconvertedintoapngasfollows:

c2c--deps<target>dot-Tpngoutput/target/deps.dot>image.png

Toseeallavailableoptions,run:

c2c-hc2tags

c2tagsisC2'sversionofctags.Thistoolisusedbyvim(e.a.)to"jumptodefinition".Seetheinstallationdocumentonhowtoinstall.

Howitworksisasfollows:

use--refsoradd$refsinrecipe.txttogeneraterefsfileduringcompilation.c2cgeneratesarefsfilepertarget.Thisfilecontainsallreferencesandtheirrespectivedestinations.c2tagscurrentlydoesn'thaveafull-blownvim-pluginyet,butasmallcode-fragmentinyour.vimrcshouldsuffice.Pressingctrl-h(configurable)withyourcursoronanysymbolwilljumptoitsdefinition.Pressingctrl-o(default)willjumpback.

Justlikec2citself,c2tagscanbecalledfromany(sub)directoryintheprojecttree.

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论