PleaseseeC2Lang.orgformoreinfoaboutC2!
TheC2projectattemptstocreateanewlanguage,stronglybasedonC.Inanutshell,themaindifferenceswithCare:
nomoreheaderfiles(toomuchtyping)noincludespackages(neededifwecan'thaveincludes)compiledpertarget(notperfile)morelogicalkeywords(public/localreplacesstatic)integratedbuildsystemBelowaretheinstructionsforbuildingandusingtheC2Compiler.
Havefun!(andcode..)
GenericC2isbasedonLLVM7.0andsomepartsofClang7.0.ThedesignofC2C'sParserandASTBuilderclassesareheavilybasedonclang'sParserandSemaclass,soherebymythankstotheClangfolks!
WhatneedstobedoneAshortlistofopenitems(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-greponlyfilesinrecipeInstallationReadtheinstallationdocumentforinstallationonLinuxorOSX.ForWindowsinstallation,seewindowsinstallationdocument.
UsingtheC2compilerBydefault,c2cwillonlyparseandanalysethetargets.GeneratingC-codeshouldworkonallexamples,butgeneratingLLVM'sIRcodeisworkinprogress.Intheexamplesdirectory:(oradd-dexamples/)
c2cmultic2chelloc2cpuzzlec2c-Iworking_irIt'salsopossibletomanuallycompileasingle.c2filewithoutarecipefilewith:
c2c-f<file.c2>TogenerateANSI-Ccode,use:
c2c-C<target>TheC2compilerisabletogenerateapackagedependencyfileindotformat.Thisfilecanbeconvertedintoapngasfollows:
c2c--deps<target>dot-Tpngoutput/target/deps.dot>image.pngToseeallavailableoptions,run:
c2c-hc2tagsc2tagsisC2'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.
评论