SrcML

srcML
Developer(s)Michael L. Collard Jonathan I. Maletic
Written inC, C++, Java
LicenseGPL
Websitewww.srcml.org

srcML (source M L) is a document-oriented XML representation of source code. It was created in a collaborative effort between Michael L. Collard and Jonathan I. Maletic. The abbreviation, srcML, is short for Source Markup Language. srcML wraps source code (text) with information from the Abstract Syntax Tree or AST (tags) into a single XML document. All original text is preserved so that the original source code document can be recreated from the srcML markup. The only exception is the possibility of newline normalization.[1]

The purpose of srcML is to provide full access to the source code at the lexical, documentary, structural, and syntactic levels. The format also provides easy support for fact-extraction and transformation. It is supported by the srcML toolkit maintained on the srcML website and has been shown to perform scalable, lightweight fact-extraction and transformation.

srcML toolkit

The srcML toolkit consists of the command-line program called srcml, which translates from source code to srcML when provided a code file on the command line or translates from srcML to source code when a srcml archive is provided on the command line. The program also supports direct queries and transformations of srcML archives using tools like XPath, XSLT, and RELAXNG. The srcML toolkit is actively maintained and currently support C, C++, C#, and Java.

srcML format

The srcML format consists of all text from the original source code file plus XML tags. Specifically, the text is wrapped with srcML elements that indicate the syntactic structure of the code. In short, this explicitly identifies all syntactic structures in the code.[2]

The tags used in srcML are listed out below along with what category they fall within.

Category srcML Elements
File/Project unit
Statement asm, block, break, case, comment, condition, constraint, continue, decl, decl_stmt, default, do else empty_stmt, enum, expr, expr_stmt, extern, for, goto, if, incr, index, init, label, macro, name, namespace, range, requires, switch, template, then, type, typedef, using, while
Function/Method argument, argument_list, call, function, function_decl, param, parameter_list, return, specifier
Class class, class_decl, constructor, constructor_decl, destructor, destructor_decl, friend, member_list, private, protected, public, super
Struct and Union struct, struct_decl, union, union_decl
Exception catch, throw, throws, try
C-Preprocessor cpp:define, cpp:directive, cpp:elif, cpp:endif, cpp:error, cpp:file, cpp:if, cpp:ifdef, cpp:ifndef, cpp:include, cpp:line, cpp:pragma, cpp:undef
K&R C krparam, krparameter_list
Java extends, finally, implements, import, package
Extra Markup lit:literal, type:modifier, op:operator
Debug marker, mode, parse
Misc escape

srcML uses XML namespaces. Below is a list of the prefix used to denote each namespace, and the namespaces themselves.

Prefix Namespace
src http://www.srcml.org/srcML/src
cpp http://www.srcml.org/srcML/cpp
pos http://www.srcml.org/srcML/position
lit http://www.srcml.org/srcML/literal
err http://www.srcml.org/srcML/srcerr

Note: for a srcML archive, the entire project will be contained within a single root unit element, and each individual file will be contained as a unit element within the root unit element.

Single file conversion

The following shows how srcml can be used on single files.

The following example converts the C++ file main.cpp to the srcML file main.cpp.xml:

srcml main.cpp -o main.cpp.xml

The following command will extract the source code from the file main.cpp.xml and place it into the C++ file main.cpp:

srcml main.cpp.xml -o main.cpp

Project conversion

The following shows how src2srcml and srcml2src can be used with an entire project:

The following example converts the project 'project' to the srcML file project.xml

srcml project -o project.xml

The following command will extract the source code files from the file project.xml and place it into the directory project:

srcml —to-dir project project.xml

Program transformation with srcML

srcML allows the use of most if not all current XML APIs and tools to write transformations. It also allows for the use of XSLT directly using the argument—xslt={name}.xls on the srcml2src command. Using srcML's markup with XSLT allows the user to apply Program Transformations on an XML-like structure(srcML) to obtain transformed xml which can then be written back its source code representation using the srcml2src tool. The application of srcML to program transformation is explained, in detail, by Collard et al.[1]

The following command will run the XSLT program program.xsl on the srcML archive project.xml

srcml —xslt program.xsl project.xml

Fact extraction with srcML

In it simplest form, Fact Extraction using srcML leverages XPath in order to address parts of the srcML document and pull information about various entities or characteristics of the source code. Of course, it is not limited to this. Any standard XML API may be used. The application of srcML to fact extraction is explained, in detail, by Kagdi et al.[3]

cpp:directive, cpp:file, cpp:include, cpp:define, cpp:undef, cpp:line, cpp:if, cpp:ifdef, cpp:ifndef, cpp:else, cpp:elif, cpp:endif, cpp:then, cpp:pragma, cpp:errorliteral, operator, modifier An example to create a srcML archive from an entire software project.

The following command runs the XPath path on a srcML archive project.xml

srcml —xpath "xpath" project.xml

Work is being done on providing convenient extension functions.

Source code difference analysis with srcML

srcML brings a lot of advantages to doing difference analysis on source code. One of these advantages is the ability to query for differences between specific sections of a codebase as well as across versions of the same codebase. The application of srcML for difference Analysis is explained, in detail, by Maletic et al.[4]

Examples

As an example of how srcML is used, here is an XPath expression that could be used to find all classes in a source document:

//src:class

Another example might be finding all comments within functions:

/src:function//src:comment

Due to the fact that srcML is based on xml, all XML tools can be used with srcML, which provides rich functionality.

See also

References

  1. ^ a b Collard, M.L., Decker, M., Maletic, J. I. (2011). Lightweight Transformation and Fact Extraction with the srcML Toolkit. Proceedings of the 11th IEEE International Working Conference on Source Code Analysis and Manipulation (SCAM'11). pp. 10 pages.{{cite book}}: CS1 maint: multiple names: authors list (link)
  2. ^ Collard, M.L, Maletic, J. I., Robinson, B.P. (2010). A Lightweight Transformational Approach to Support Large Scale Adaptive Changes. Proceedings of the IEEE 26th IEEE International Conference on Software Maintenance (ICSM'10). pp. 10 pages.{{cite book}}: CS1 maint: multiple names: authors list (link)
  3. ^ Collard, Michael L., Kagdi, Huzefa, Maletic, Jonathan I. (2003). An XML-Based Lightweight C++ Fact Extractor. Proceedings of the 11th IEEE International Workshop on Program Comprehension (IWPC'03). pp. 10 pages.{{cite book}}: CS1 maint: multiple names: authors list (link)
  4. ^ Maletic, Jonathan I., Collard, Michael L. (2004). Supporting Source Code Difference Analysis. Proceedings of the IEEE International Conference on Software Maintenance (ICSM'04). pp. 10 pages.{{cite book}}: CS1 maint: multiple names: authors list (link)
  • Maletic, Jonathan I., Collard, Michael L., Kagdi, Huzefa (2004). Leveraging XML Technologies in Developing Program Analysis Tools. Proceedings of the 4th International Workshop on Adoption-Centric Software Engineering (ACSE'04). pp. 6 pages.{{cite book}}: CS1 maint: multiple names: authors list (link)
  • Collard, Michael L., Maletic, Jonathan I., Marcus, Andrian (2002). Supporting Document and Data Views of Source Code. Proceedings of the 2nd ACM Symposium on Document Engineering (DocEng'02). pp. 8 pages.{{cite book}}: CS1 maint: multiple names: authors list (link)
  • Maletic, Jonathan I., Collard, Michael L., Marcus, Andrian (2002). Source Code Files as Structured Documents. Proceedings of the 10th IEEE International Workshop on Program Comprehension (IWPC'02). pp. 4 pages.{{cite book}}: CS1 maint: multiple names: authors list (link)

Read other articles:

Petre Marin Datos personalesApodo(s) JairNacimiento Bucarest, Rumanía8 de septiembre de 1973 (50 años)Nacionalidad(es) Carrera deportivaDeporte FútbolClub profesionalDebut deportivo 2004(Sportul Studențesc)Posición Lateral derecho e izquierdoSelección nacionalPart. 8 ocasiones[editar datos en Wikidata] Petre Marin, apodado Jair, es un exfutbolista rumano, nacido el 8 de septiembre de 1973 en Bucarest. Su posición natural es lateral derecho e izquierdo. Su último equipo ...

 

此條目翻譯品質不佳。 (2022年9月10日)翻譯者可能不熟悉中文或原文語言,也可能使用了機器翻譯。請協助翻譯本條目或重新編寫,并注意避免翻译腔的问题。明顯拙劣的翻譯請改掛{{d|G13}}提交刪除。 此條目可参照英語維基百科相應條目来扩充。 (2022年9月10日)若您熟悉来源语言和主题,请协助参考外语维基百科扩充条目。请勿直接提交机械翻译,也不要翻译不可靠、低品...

 

Johann Peter Theodor Janssen Johann Peter Theodor Janssen, genannt Peter Janssen der Ältere (* 12. Dezember 1844 in Düsseldorf; † 19. Februar 1908 ebenda), war ein deutscher Historienmaler der Düsseldorfer Schule. Von 1895 bis 1908 war er Direktor der Kunstakademie Düsseldorf. Inhaltsverzeichnis 1 Leben 2 Werk 2.1 Illustrationen für Bücher 3 Schüler (Auswahl) 4 Literatur 5 Weblinks 6 Einzelnachweise Leben Peter Janssen wurde als erster Sohn des Kupferstechers Tamme Weyert Theodor Jan...

Ivan Bojničić-Kninski (von Theodor Mayerhofer, 1894) Ivan Bojničić (* 24. Dezember 1858 in Valpovo, Slawonien; † 11. Juni 1925 in Zagreb) war ein Jurist, Archivdirektor und Heraldiker. Inhaltsverzeichnis 1 Leben 2 Werke (Auswahl) 3 Literatur 4 Weblinks Leben Bojničić absolvierte ein Studium der Rechtswissenschaft in Osijek, Budapest und Wien. Er promovierte zum Doktor der Philosophie. Von 1879 bis 1894 war er Kustos der archäologischen Abteilung des kroatischen Nationalmuseums. Ab 18...

 

  لمعانٍ أخرى، طالع زولتان سابو (توضيح). زولتان سابو معلومات شخصية الميلاد 24 نوفمبر 1965 (58 سنة)  بودابست  مواطنة المجر  عضو في الأكاديمية المجرية للعلوم  الحياة العملية المدرسة الأم جامعة روتجرز (الشهادة:دكتوراه في الفلسفة) (–1994)جامعة أوتفوش لوراند (–1990)  مشر...

 

Edi JuardiInformasi pribadiLahir24 Desember 1965 (umur 57)Bandung IndonesiaKebangsaanIndonesiaAlma materAkademi Angkatan Laut (1989)PekerjaanTNI NRP.9646/PKarier militerPihak IndonesiaDinas/cabang TNI Angkatan LautMasa dinas1989—2024Pangkat Mayor Jenderal TNI (Mar)SatuanKorps MarinirSunting kotak info • L • B Mayor Jenderal TNI (Purn.) (Mar) Edi Juardi (lahir 24 Desember 1965) adalah seorang Purnawirawan TNI-AL yang terakhir menjabat Staf Khusus Kasal.[1]...

2004 studio album by Death from Above 1979You're a Woman, I'm a MachineStudio album by Death from Above 1979ReleasedOctober 26, 2004RecordedFebruary–April 2004Studio The Chemical Sound Studio Plateau Genre Dance-punk[1] noise rock[2] Length35:03LabelLast GangProducerAl-PDeath from Above 1979 chronology Heads Up!(2002) You're a Woman, I'm a Machine(2004) The Physical World(2014) Singles from You're a Woman, I'm a Machine Romantic RightsReleased: November 4, 2004 Blood...

 

Species of bat Western naked-backed fruit bat Conservation status Least Concern (IUCN 3.1)[1] Scientific classification Domain: Eukaryota Kingdom: Animalia Phylum: Chordata Class: Mammalia Order: Chiroptera Family: Pteropodidae Genus: Dobsonia Species: D. peronii Binomial name Dobsonia peronii(É. Geoffroy, 1810) Western naked-backed fruit bat range The western naked-backed fruit bat (Dobsonia peronii) is a species of megabat in the family Pteropodidae. It is endemic to Indo...

 

سعدين كلا  - قرية -  تقسيم إداري البلد إيران  الدولة  إيران المحافظة مازندران المقاطعة مقاطعة آمل الناحية الناحية المركزية القسم الريفي قسم هرازبي الجنوبی الريفي إحداثيات 36°32′17″N 52°21′32″E / 36.53806°N 52.35889°E / 36.53806; 52.35889 السكان التعداد السكاني 383 نسم...

Historic site in Badwater Basin, Death ValleyBennett-Arcane Long CampBadwater Basin, Bennett-Arcane Long Camp was left center of photoLocationBadwater Basin, Death ValleyCoordinates36°09′48″N 116°51′48″W / 36.1634°N 116.863372222222°W / 36.1634; -116.863372222222 California Historical LandmarkOfficial nameCamBennett-Arcane Long CampDesignatedOctober 24, 1949Reference no.444[1] Bennett-Arcane Long Camp was a 1849er camp set up in December 1849 i...

 

2nd century Christian apologetic text Part of a series onNew Testament apocryphaFirst page of the Gospel of Judas(Page 33 of Codex Tchacos) Apostolic Fathers 1 Clement 2 Clement Epistles of Ignatius Polycarp to the Philippians Martyrdom of Polycarp Didache Barnabas Diognetus The Shepherd of Hermas Apocryphal gospels Jewish–Christian gospels Ebionites Hebrews Nazarenes Infancy gospels James Thomas Syriac Pseudo-Matthew History of Joseph the Carpenter Gnostic gospels Judas Mary Philip Truth S...

 

American tennis player (born 2004) Coco GauffGauff at the 2022 US OpenCountry (sports) United StatesBorn (2004-03-13) March 13, 2004 (age 19)Delray Beach, Florida, U.S.Height5 ft 9 in (1.75 m)Turned pro2018PlaysRight-handed (two-handed backhand)CoachPere Riba (2023)Brad Gilbert (2023–)Prize moneyUS$12,219,713[1]SinglesCareer record173–80 (68.4%)Career titles6Highest rankingNo. 3 (September 11, 2023)Current rankingNo. 3 (Septem...

Amine Gemayelأمين الجميٌلAmine Gemayel pada 1982Presiden Lebanon 7Masa jabatan23 September 1982 – 22 September 1988PendahuluElias Sarkis,Bachir Gemayel (terpilih)PenggantiRené Moawad Informasi pribadiLahir22 Januari 1942 (umur 81)Bikfaya, Lebanon BesarKebangsaanLebanonPartai politikPartai KataebSuami/istriJoyce Tyan ​(m. 1967)​AnakNicolePierreSamyAlma materUniversitas Santo YusufSitus webSitus web resmiSunting kotak info • L&...

 

2016 British filmThe Exorcism of Anna EcklundFilm posterDirected byAndrew JonesWritten byAndrew JonesProduced byAndrew JonesEmily CouplandSteve BeechamStarringJeff RaggettLee Bane Tiffany CeriCinematographyJonathan McLaughlinEdited byAndrew JonesMusic byBobby ColeProductioncompanyMasterplan Film ProductionsRelease date 7 March 2016 (2016-03-07) Running time76 minutesCountryUnited KingdomLanguageEnglishBox office$43,300 The Exorcism of Anna Ecklund is a 2016 British horror film ...

 

13th (Service) Battalion (Wandsworth), East Surrey RegimentCap Badge, 13th East Surrey RegimentActive16 June 1915- 3 November 1918Country United KingdomBranch British ArmyTypeInfantryRoleLine InfantrySizeBattalionPart ofEast Surrey RegimentGarrison/HQWitleyEngagementsWestern Front (World War I)Military unit The 13th (Service) Battalion (Wandsworth), East Surrey Regiment was a British New Army infantry battalion during the First World War. Formed in 1915 as a hostilities-only battali...

Online database of DOS video games This article's lead section may be too long. Please read the length guidelines and help move details into the article's body. (November 2020) AbandoniaA screenshot of the main page.Type of siteAbandonware video gamesOwnerAbovo Media Group, SwedenCreated byKosta KrauthURLwww.abandonia.comCommercialNoRegistrationnot requiredLaunched1999-06-21Current statusActive Abandonia is an abandonware website, focusing mainly on showcasing video games and distri...

 

British sports car racing team JOTAFounded2000Founder(s)Sam Hignett, John StackBaseKent, UKTeam principal(s)Sam Hignett (Partner & Team Principal), David Clark (Partner & Commercial Director)Current series24 Hours of Le MansFIA World Endurance ChampionshipGT World Challenge Europe Endurance CupGT World Challenge Europe Sprint CupFormer seriesAsian Le Mans SeriesWeatherTech SportsCar ChampionshipFIA Sportscar ChampionshipPorsche Carrera Cup Great BritainPorsche SupercupEuropean Le Mans...

 

1993 single by Things of Stone and WoodSingle Perfect RaindropCD single coverSingle by Things of Stone and Woodfrom the album The Yearning ReleasedJune 1993Length4:08LabelCapitolSongwriter(s)Greg ArnoldProducer(s)James Black, Martin PullanThings of Stone and Wood singles chronology Rock This Boat (1993) Single Perfect Raindrop (1993) Wildflowers (1994) Single Perfect Raindrop is a song written by Greg Arnold and recorded by Australian folk-rock band Things of Stone and Wood. The song was rele...

Chinese writer (1895–1976) In this Chinese name, the family name is Lin (林). Lin Yutang林語堂Lin Yutang, photographed byCarl Van Vechten, 1939Born(1895-10-10)October 10, 1895Banzai, Pinghe, Zhangzhou, FujianDiedMarch 26, 1976(1976-03-26) (aged 80)British Hong KongAlma materSaint John's UniversityHarvard University Leipzig UniversityOccupation(s)Linguist, novelist, philosopher, translator Lin YutangTraditional Chinese林語堂Simplified Chinese林语堂Hokkien POJLîm Gí...

 

This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Customs and etiquette in Chinese dining – news · newspapers · books · scholar · JSTOR (May 2013) (Learn how and when to remove this template message) Part of a series onChinese cuisine Regional cuisines Four Great Traditions Chuan (Sichuan) Lu (Shandong) Yue (G...

 

Strategi Solo vs Squad di Free Fire: Cara Menang Mudah!