Download presentation
Presentation is loading. Please wait.
1
M.Sc. of Advanced Software Engineering CO7206 System Reengineering XML & AST Many Slides are by Georgios Koutsoukos
2
Objectives To give some knowledge about core technologies used in CARE This lecture covers: –XML –AST
3
Outline What is XML How can XML be used The importance of XML and its use in CARE What is an AST AST example and its importance in CARE
4
Related Readings Al-Ekram & Kontogiannis, An XML-based Framework for Language Neutral Program Representation and Generic Analysis Available at: –http://swag.uwaterloo.ca/~rekram/publications/csmr2005--xml- based-framework-for-language-neutral-program-representation- and-analysis.pdf http://swag.uwaterloo.ca/~rekram/publications/csmr2005--xml- based-framework-for-language-neutral-program-representation- and-analysis.pdfhttp://swag.uwaterloo.ca/~rekram/publications/csmr2005--xml- based-framework-for-language-neutral-program-representation- and-analysis.pdf Useful links: –http://www.w3schools.com/xml/default.asp http://www.w3schools.com/xml/default.asp –http://www.mulberrytech.com/quickref/XMLquickref.pdf http://www.mulberrytech.com/quickref/XMLquickref.pdf
5
What is XML XML stands for eXtensible Markup Language XML is a markup language much like HTML XML is used to describe structured data XML data is stored in plain-text format i.e software and hardware-independent XML tags are not predifined. One must define its own tags. XML may use a Document Type Definition (DTD) or an XML Schema to describe the data
6
XML Vs HTML XML and HTML were designed with different goals: –XML was designed to describe data and to focus on what data is. –HTML was designed to display data and to focus on how data looks. HTML tags are predifined
7
How can XML be used XML can be used to: –Separate data from its presentation –Exchange data between incompatible systems –Share data between different applications –Store data In fact, currently XML is the de-facto standard in many software application areas such as Web content description, Web-Services and Communication Protocols (e.g SOAP) among many others.
8
XML Syntax (1) XML Declaration contains: –Version of the XML specification –Character encoding of the document XML Tags must: –Be case sensitive –Start with letter or underscore –Not contain whitespaces –Have an end Tag
9
XML Syntax (2) Element Declaration –Elements must be properly nested –All XML documents must have a root element Attribute Declaration –Atributes provide metadata for the element –Atributes must be enclosed in “” with no commas between –Same naming conventions as elements
10
An XML example The following is a very simple example of an XML document representing data of pets: Max Toula Max Toula
11
XML and L-CARE Why should one care about XML in order to use L-CARE? In fact one does not have to care about XML, but about XPath which is the language for identifying parts of XML documents. L-CARE uses the XPath language in order to write markers for identifying patterns of code. XPath shall be explained in a future class.
12
What is an AST AST stands for Abstract Syntax Tree Abstract Syntax Trees are the basic source code representations at the finest level of granularity. AST representation provides the most detailed information from the source code.
13
AST example (1) An XML document can be viewed as an AST containing different kinds of nodes with the most widely used being the root, elements, attributes and text. For the XML example given before, the tree structure is showed in the following slide:
14
AST example (2)
15
AST and CARE Why should one care about AST in order to use L-CARE? AST is a graphical form of representing the souce code in CARE and understanding it can be great, not only to understand the source code you are working on, but also to help you build XPath queries.
16
The following piece of code: public void tick() { theCurrentTime = Calendar.getInstance() ; if(theCurrentTime!=null){ notifyObservers();}}
17
Could be represented in XML as (1): <Statements> <Expression><FunctionOp><DotOp> </FunctionOp></Expression></Assignment>
18
Could be represented in XML as (2): <If><Expression> </BinaryOp></Expression><Then><FunctionOp> </FunctionOp></Then></If></Statements></Method>
19
Or by the following tree structure:
20
Key Points XML is used by many tools as an attempt to describe data in an Universal way. XML is used in CARE to represent source code and make marking and transforming it easier and more performant. ASTs are graphical representations of source code and are useful to understand it. There is a close connection between an XML representation and the corresponding AST.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.