ICE1341 Programming Languages Spring 2005 Lecture #8 Lecture #8 In-Young Ko iko.AT. icu.ac.kr iko.AT. icu.ac.kr Information and Communications University.

Slides:



Advertisements
Similar presentations
XML: Extensible Markup Language
Advertisements

Names and Bindings.
Various languages….  Could affect performance  Could affect reliability  Could affect language choice.
ISBN Chapter 5 Names, Bindings, Type Checking, and Scopes.
CS 330 Programming Languages 10 / 16 / 2008 Instructor: Michael Eckmann.
Names, Bindings, Type Checking, and Scopes
ISBN Chapter 5 Names, Bindings, Type Checking, and Scopes Names Variables The Concept of Binding Type Checking Strong Typing Type Compatibility.
Thayer School of Engineering Dartmouth Lecture 2 Overview Web Services concept XML introduction Visual Studio.net.
ISBN Lecture 05 Variable Attributes.
The Concept of Variables
Copyright © 1995 by Addison-Wesley Publishing Co. 1 Names - Design issues: - Maximum length? - Are connector characters allowed? - Are names case sensitive?
Names and Bindings Introduction Names Variables The concept of binding Chapter 5-a.
ICE1341 Programming Languages Spring 2005 Lecture #3 Lecture #3 In-Young Ko iko.AT. icu.ac.kr iko.AT. icu.ac.kr Information and Communications University.
Names, Bindings, and Scopes
Software II: Principles of Programming Languages Lecture 5 – Names, Bindings, and Scopes.
1 Chapter 5: Names, Bindings and Scopes Lionel Williams Jr. and Victoria Yan CSci 210, Advanced Software Paradigms September 26, 2010.
March 19, ICE 1341 – Programming Languages (Lecture #8) In-Young Ko Programming Languages (ICE 1341) Lecture #8 Programming Languages (ICE 1341)
Names, Bindings, Type Checking, and Scopes
ISBN Chapter 5 Names, Bindings, Type Checking, and Scopes.
Chapter 5 © 2002 by Addison Wesley Longman, Inc Names - We discuss all user-defined names here - Design issues for names: - Maximum length? - Are.
COMP4730/2003/lec5/H.Melikian Names, Bindings,Type Checking and Scopes (Chapter 5) - Design issues: - Maximum length? - Are connector characters allowed?
CSC3315 (Spring 2009)1 CSC 3315 Programming Languages Hamid Harroud School of Science and Engineering, Akhawayn University
1 Chapter 5 Names Bindings Type Checking Scope. 2 High-Level Programming Languages Two main goals:Two main goals: –Machine independence –Ease of programming.
1 CS Programming Languages Class 07 September 14, 2000.
Names Variables Type Checking Strong Typing Type Compatibility 1.
Names, Bindings, Type Checking, and Scopes
5-1 Chapter 5: Names, Bindings, Type Checking, and Scopes Variables The Concept of Binding Type Checking Strong Typing Type Compatibility Scope and Lifetime.
Electronic Commerce COMP3210 Session 4: Designing, Building and Evaluating e-Commerce Initiatives – Part II Dr. Paul Walcott Department of Computer Science,
March 12, ICE 1341 – Programming Languages (Lecture #6) In-Young Ko Programming Languages (ICE 1341) Lecture #6 Programming Languages (ICE 1341)
Chapter 5 Names, Bindings, and Scopes. Copyright © 2012 Addison-Wesley. All rights reserved.1-2 Chapter 5 Topics Introduction Names Variables The Concept.
ISBN Chapter 5 Names, Bindings, and Scopes.
Introduction A variable can be characterized by a collection of properties, or attributes, the most important of which is type, a fundamental concept in.
1 Type Checking Type checking ensures that the operands and the operator are of compatible types Generalized to include subprograms and assignments Compatible.
ISBN Chapter 5 Names, Bindings, and Scopes.
CSC3315 (Spring 2008)1 CSC 3315 Subprograms Hamid Harroud School of Science and Engineering, Akhawayn University
Introduction to XML This presentation covers introductory features of XML. What XML is and what it is not? What does it do? Put different related technologies.
Lecture 16 Introduction to XML Boriana Koleva Room: C54
Web Technologies COMP6115 Session 4: Adding a Database to a Web Site Dr. Paul Walcott Department of Computer Science, Mathematics and Physics University.
April 2, ICE 1341 – Programming Languages (Lecture #12) In-Young Ko Programming Languages (ICE 1341) Lecture #12 Programming Languages (ICE 1341)
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.
Structure of Programming Languages Names, Bindings, Type Checking, and Scopes.
Concepts of programming languages Chapter 5 Names, Bindings, and Scopes Lec. 12 Lecturer: Dr. Emad Nabil 1-1.
ISBN Chapter 5 Names, Bindings, Type Checking, and Scopes.
Names and Binding In Text: Chapter 4.
ISBN Variables, Names, Scope and Lifetime ICOM 4036 Lecture 9.
1 Structure of Compilers Lexical Analyzer (scanner) Modified Source Program Parser Tokens Semantic Analysis Syntactic Structure Optimizer Code Generator.
Working with XML. Markup Languages Text-based languages based on SGML Text-based languages based on SGML SGML = Standard Generalized Markup Language SGML.
CS 330 Programming Languages 10 / 23 / 2007 Instructor: Michael Eckmann.
ISBN Chapter 5 Names, Bindings, Type Checking, and Scopes.
C Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Introduction to XML Standards.
Names, Scope, and Bindings Programming Languages and Paradigms.
Names, Bindings, Type Checking and Scopes. Chapter 5 Topics Introduction Names Variables The Concept of Binding Type Checking Strong Typing Type Equivalence.
ISBN Chapter 5 Names, Bindings, Type Checking, and Scopes.
Chapter 5 Names, Bindings, Type Checking CSCE 343.
5.2 Names - We discuss all user-defined names here
5.2 Names - We discuss all user-defined names here
Object Lifetime and Pointers
Type Checking Generalizes the concept of operands and operators to include subprograms and assignments Type checking is the activity of ensuring that the.
Type Checking, and Scopes
Chapter 5 Names, Bindings, Type Checking, and Scopes.
Names, Bindings, and Scopes
XML in Web Technologies
Chapter 5 Names, Bindings, Type Checking, and Scopes.
Names, Bindings, Type Checking, and Scopes
Names, Bindings, Type Checking, and Scopes
Names and Binding In Text: Chapter 5.
Names, Bindings, and Scopes
Presentation transcript:

ICE1341 Programming Languages Spring 2005 Lecture #8 Lecture #8 In-Young Ko iko.AT. icu.ac.kr iko.AT. icu.ac.kr Information and Communications University (ICU)

Spring ICE 1341 – Programming Languages © In-Young Ko, Information and Communications University Announcements The due date of the midterm project is postponed to Thursday April 14 th (a week after the midterm exam) The due date of the midterm project is postponed to Thursday April 14 th (a week after the midterm exam) There will be the project presentation session on the due date There will be the project presentation session on the due date

Spring ICE 1341 – Programming Languages © In-Young Ko, Information and Communications University Axiomatic Semantics (cont.) Axiomatic Semantics (cont.) Names Names Variables Variables Bindings Bindings Binding Lifetimes Binding Lifetimes Last Lecture

Spring ICE 1341 – Programming Languages © In-Young Ko, Information and Communications University This Lecture Binding Lifetimes (cont.) Binding Lifetimes (cont.) WWW Concepts WWW Concepts WWW Languages WWW Languages XML (Extended Markup Language) XML (Extended Markup Language)

Spring ICE 1341 – Programming Languages © In-Young Ko, Information and Communications University Program Memory Structure Static Area Static Area Program code Program code Non-local variables Non-local variables Static variables Static variables Dynamic Storage Dynamic Storage Stack Area Stack Area Local variables Local variables Parameters and return values Parameters and return values Heap Area Heap Area Dynamically allocated memory blocks Dynamically allocated memory blocks Dynamic storage control e.g., java –xm1024m MyProgram Stack Area Static Area Heap Area … Dynamic Storage

Spring ICE 1341 – Programming Languages © In-Young Ko, Information and Communications University Binding Lifetimes Static: Storage bindings remain throughout execution Static: Storage bindings remain throughout execution e.g. all FORTRAN 77 variables, Java static variables Advantages: efficiency (direct addressing); history-sensitive subprogram support Advantages: efficiency (direct addressing); history-sensitive subprogram support Disadvantage: lack of flexibility (no recursion) Disadvantage: lack of flexibility (no recursion) Stack-Dynamic: Storage bindings are created when their declaration statements are elaborated Stack-Dynamic: Storage bindings are created when their declaration statements are elaborated e.g. local variables in C subprograms and Java methods Advantage: allows recursion; conserves storage Advantage: allows recursion; conserves storage Disadvantages: overhead of allocation and deallocation; subprograms cannot be history sensitive; slower accesses (indirect addressing) Disadvantages: overhead of allocation and deallocation; subprograms cannot be history sensitive; slower accesses (indirect addressing) * AW Lecture Notes

Spring ICE 1341 – Programming Languages © In-Young Ko, Information and Communications University Binding Lifetimes – cont. Explicit Heap-Dynamic: Storages are allocated and deallocated by explicit directives, specified by the programmer, which take effect during execution Explicit Heap-Dynamic: Storages are allocated and deallocated by explicit directives, specified by the programmer, which take effect during execution e.g. dynamic objects in C++ (via new and delete) all objects in Java (new int[100]) all objects in Java (new int[100]) Advantage: provides for dynamic storage management Advantage: provides for dynamic storage management Disadvantage: inefficient and unreliable Disadvantage: inefficient and unreliable Implicit Heap-Dynamic: Storages are allocation and deallocation caused by assignment statements Implicit Heap-Dynamic: Storages are allocation and deallocation caused by assignment statements e.g. all variables in APL; all strings and arrays in Perl and JavaScript Advantage: flexibility Advantage: flexibility Disadvantages: inefficient, because all attributes are dynamic; loss of error detection by the compiler Disadvantages: inefficient, because all attributes are dynamic; loss of error detection by the compiler * AW Lecture Notes

Spring ICE 1341 – Programming Languages © In-Young Ko, Information and Communications University Type Checking Type Checking: the activity of ensuring that the operands of an operator are of compatible types Type Checking: the activity of ensuring that the operands of an operator are of compatible types Compatible Type: a type that is either legal for an operator, or is allowed under language rules to be implicitly converted to a legal type (coercion) Compatible Type: a type that is either legal for an operator, or is allowed under language rules to be implicitly converted to a legal type (coercion) Type Error: the application of an operator to an operand of an inappropriate type Type Error: the application of an operator to an operand of an inappropriate type A programming language is strongly typed if type errors are always detected A programming language is strongly typed if type errors are always detected * AW Lecture Notes

Spring ICE 1341 – Programming Languages © In-Young Ko, Information and Communications University Type Compatibility Name Type Compatibility: two variables have compatible types if they are in either the same declaration or in declarations that use the same type name Name Type Compatibility: two variables have compatible types if they are in either the same declaration or in declarations that use the same type name Easy to implement but highly restrictive Easy to implement but highly restrictive Subranges of integer types are not compatible with integer types Subranges of integer types are not compatible with integer types e.g.,type Indextype is ; count: Integer; index: Indextype; Formal parameters must be the same type as their corresponding actual parameters (Pascal) Formal parameters must be the same type as their corresponding actual parameters (Pascal) Structure Type Compatibility: two variables have compatible types if their types have identical structures Structure Type Compatibility: two variables have compatible types if their types have identical structures More flexible, but harder to implement More flexible, but harder to implement

Spring ICE 1341 – Programming Languages © In-Young Ko, Information and Communications University Type Compatibility – cont. Derived Type: a new type that is based on some previously defined type Derived Type: a new type that is based on some previously defined type Derive types inherit all the properties of their parent types Derive types inherit all the properties of their parent types Derived types allow types with the same structure to be different Derived types allow types with the same structure to be different e.g., type celsius is new Float; type fahrenheit is new Float; type fahrenheit is new Float; Subtype: a range-constrained version of an existing type Subtype: a range-constrained version of an existing type A subtype is compatible with its parent type A subtype is compatible with its parent type e.g., subtype Small_type is Integer range 0..99; Anonymous Type: Unnamed type Anonymous Type: Unnamed type Anonymous types are all unique, even in Anonymous types are all unique, even in e.g., C, D : array (1..10) of Integer;

Spring ICE 1341 – Programming Languages © In-Young Ko, Information and Communications University The World Wide Web (WWW) “Information Management: A Proposal”, Tim Berners- Lee, CERN, March 1989 “Information Management: A Proposal”, Tim Berners- Lee, CERN, March 1989CERN A proposal to build a global hypertext system for CERN A proposal to build a global hypertext system for CERN proposal.html proposal.html proposal.html proposal.html The original proposal of the WWW

Spring ICE 1341 – Programming Languages © In-Young Ko, Information and Communications University WWW Concepts Hypertext Universal Readership Searching Client-Server Model FormatNegotiation Image formatsImage formats Text fontsText fonts FramesFrames

Spring ICE 1341 – Programming Languages © In-Young Ko, Information and Communications University Languages for WWW HTML (Hypertext Markup Language) HTML (Hypertext Markup Language) Scripting Languages (e.g., Perl, JavaScript) Scripting Languages (e.g., Perl, JavaScript) XML (Extended Markup Language) XML (Extended Markup Language) RDF (Resource Description Framework) RDF (Resource Description Framework) DAML (DARPA Agent Markup Language) DAML (DARPA Agent Markup Language) SOAP (Simple Object Access Protocol) SOAP (Simple Object Access Protocol) WSDL (Web Services Description Language) WSDL (Web Services Description Language) WSFL (Web Services Flow Language) WSFL (Web Services Flow Language) …

Spring ICE 1341 – Programming Languages © In-Young Ko, Information and Communications University SGML (Standard Generalized Markup Language) SGML is a meta-markup language developed in the early 1980s (ISO 8879, 1986) SGML is a meta-markup language developed in the early 1980s (ISO 8879, 1986)ISO 8879ISO 8879 HTML was developed using SGML in the early 1990s - specifically for Web documents HTML was developed using SGML in the early 1990s - specifically for Web documents Problems with HTML: Problems with HTML: 1. Fixed set of tags and attributes User cannot define new tags or attributes User cannot define new tags or attributes So, the tags cannot connote any particular meaning So, the tags cannot connote any particular meaning 2. No restrictions on arrangement or order of tag appearance SGML is too large and complex to use, and it is very difficult to build a parser for it SGML is too large and complex to use, and it is very difficult to build a parser for it AW lecture notes

Spring ICE 1341 – Programming Languages © In-Young Ko, Information and Communications University XML (Extended Markup Language) XML is a light version of SGML that provides a way of storing and transferring data of any kind XML is a light version of SGML that provides a way of storing and transferring data of any kind XML vs. HTML XML vs. HTML HTML is a markup language used to describe the layout of any kind of information HTML is a markup language used to describe the layout of any kind of information XML is a meta-markup language that can be used to define markup languages that can define the meaning of specific kinds of information XML is a meta-markup language that can be used to define markup languages that can define the meaning of specific kinds of information XML does not predefine any tags XML does not predefine any tags All documents described with an XML-derived markup language can be parsed with a single parser All documents described with an XML-derived markup language can be parsed with a single parser AW lecture notes

Spring ICE 1341 – Programming Languages © In-Young Ko, Information and Communications University A Sample XML Document <class> Prog. Lang. Prog. Lang. ICE1341 ICE1341 <students> K.D. Ko K.D. Ko </student> C.S. Lee C.S. Lee </student></students></class>

Spring ICE 1341 – Programming Languages © In-Young Ko, Information and Communications University XML Syntax A flexible text format that is originally designed for large-scale electronic publishing of documents A flexible text format that is originally designed for large-scale electronic publishing of documents An XML document is a hierarchical organization of one or more named elements An XML document is a hierarchical organization of one or more named elements An element is composed of an opening-tag, data (string or another element), and a closing-tag An element is composed of an opening-tag, data (string or another element), and a closing-tag An opening-tag is an element name surrounded by ‘ ’ An opening-tag is an element name surrounded by ‘ ’ A closing-tag is an element name surrounded by ‘ ’ A closing-tag is an element name surrounded by ‘ ’ An element may have zero or more attributes An element may have zero or more attributes An attribute is a name-value pair that specifies a property of the element An attribute is a name-value pair that specifies a property of the element

Spring ICE 1341 – Programming Languages © In-Young Ko, Information and Communications University XML Syntax – cont. All XML documents begin with an XML declaration: All XML documents begin with an XML declaration: XML comments are just like HTML comments XML comments are just like HTML comments XML names: XML names: Must begin with a letter or an underscore Must begin with a letter or an underscore They can include digits, hyphens, and periods They can include digits, hyphens, and periods There is no length limitation There is no length limitation They are case sensitive (unlike HTML names) They are case sensitive (unlike HTML names) Syntax rules for XML: Syntax rules for XML: Every XML document defines a single root element, whose opening tag must appear as the first line of the document Every XML document defines a single root element, whose opening tag must appear as the first line of the document Every element that has content must have a closing tag Every element that has content must have a closing tag Tags must be properly nested Tags must be properly nested All attribute values must be quoted All attribute values must be quoted AW lecture notes

Spring ICE 1341 – Programming Languages © In-Young Ko, Information and Communications University A Sample XML Document <class> Prog. Lang. Prog. Lang. ICE1341 ICE1341 <students> K.D. Ko K.D. Ko </student> C.S. Lee C.S. Lee </student></students></class> An opening-tag A closing-tag An element An attribute The root element A value

Spring ICE 1341 – Programming Languages © In-Young Ko, Information and Communications University The XML Grammar document ::= prolog element Misc* document ::= prolog element Misc* element ::= EmptyElemTag | STag content ETag element ::= EmptyElemTag | STag content ETag EmptyElemTag ::= ' ' EmptyElemTag ::= ' ' STag ::= ' ' STag ::= ' ' content ::= CharData? ((element | Reference | CDSect | PI | Comment) CharData?)* content ::= CharData? ((element | Reference | CDSect | PI | Comment) CharData?)* ETag ::= ' ' ETag ::= ' ' S ::= (#x20 | #x9 | #xD | #xA)+ S ::= (#x20 | #x9 | #xD | #xA)+ Attribute ::= Name '=' AttValue Attribute ::= Name '=' AttValue Name ::= (Letter | '_' | ':') (NameChar)* Name ::= (Letter | '_' | ':') (NameChar)* Comment ::= ' ' Comment ::= ' ' XML Spec:

Spring ICE 1341 – Programming Languages © In-Young Ko, Information and Communications University An XML Document Grammar <class> Prog. Lang. Prog. Lang. ICE1341 ICE1341 <students> K.D. Ko K.D. Ko </student> C.S. Lee C.S. Lee </student></students></class> class  “ ” node “ class  “ ” node “ node  name code students name  “ ” string “ ” code  “ ” string “ ” students  “ ” student* “ ” student  “ ” name birthday “ ” birthday  “ ” num “ ”

Spring ICE 1341 – Programming Languages © In-Young Ko, Information and Communications University XML APIs SAX (Simple API for XML) – XML-DEV SAX (Simple API for XML) – XML-DEV Stream-based Access Interface (Sequential Access) Stream-based Access Interface (Sequential Access) Notifies an application of a stream of parsing events Notifies an application of a stream of parsing events Needs a Content Handler to handle the parsing events (e.g., start and end of an element) Needs a Content Handler to handle the parsing events (e.g., start and end of an element) Appropriate to handle a large XML document Appropriate to handle a large XML document DOM (Document Object Model) – W3C DOM (Document Object Model) – W3C Object-oriented Access Interface (Random Access) Object-oriented Access Interface (Random Access) Builds a tree of nodes based on the structure and information in an XML document Builds a tree of nodes based on the structure and information in an XML document Types of nodes: Document, Element, Attr, … Types of nodes: Document, Element, Attr, …

Spring ICE 1341 – Programming Languages © In-Young Ko, Information and Communications University DOM Representation <class> Prog. Lang. Prog. Lang. ICE1341 ICE1341 Y.K. Ko Y.K. Ko D.W. Kim D.W. Kim </class> XML Document DOM Representation Document (Root Node) Elements (Child Nodes) Node Values (Text Nodes)

Spring ICE 1341 – Programming Languages © In-Young Ko, Information and Communications University XML Processors XML Parsers: read XML documents and provide access to their content and structure via DOM (e.g., Xerces, Sun’s Java XML Parser) XML Parsers: read XML documents and provide access to their content and structure via DOM (e.g., Xerces, Sun’s Java XML Parser) Document Filtering (Validation) Document Filtering (Validation) Document Type Declaration (DTD): a grammar for a class of XML documents Document Type Declaration (DTD): a grammar for a class of XML documents XML Schema (XSD): a successor of DTD. Describes the structure of an XML document XML Schema (XSD): a successor of DTD. Describes the structure of an XML document XML Presentation XML Presentation eXtensible Stylesheet Language (XSL): a language to define the transformation and presentation of an XML document eXtensible Stylesheet Language (XSL): a language to define the transformation and presentation of an XML document

Spring ICE 1341 – Programming Languages © In-Young Ko, Information and Communications University XML Processors XML Document Databases XML Parser DTD/ XMLSchema XSL Description XSL Processor XML Grammar (Structure) Validation DOM Objects HTML Presentation Parsing Events DOM API SAX API

Spring ICE 1341 – Programming Languages © In-Young Ko, Information and Communications University XML Logical Structure Examples......</patient> AW lecture notes <patient> Maggie Maggie Dee Dee Magpie Magpie......</patient> <patient> Maggie Dee Magpie Maggie Dee Magpie......</patient>

Spring ICE 1341 – Programming Languages © In-Young Ko, Information and Communications University Logical Structure of an XML Document A new nested tag needs to be defined to provide more info about the content of a tag A new nested tag needs to be defined to provide more info about the content of a tag Nested tags are better than attributes, because attributes cannot describe structure and the structural complexity may grow Nested tags are better than attributes, because attributes cannot describe structure and the structural complexity may grow Attributes should always be used to identify numbers or names of elements (like HTML id and name attributes) Attributes should always be used to identify numbers or names of elements (like HTML id and name attributes) AW lecture notes

Spring ICE 1341 – Programming Languages © In-Young Ko, Information and Communications University Related Materials W3C’s XML Web Site: W3C’s XML Web Site: XML Specification: xml / XML Specification: xml / xml / xml / XML Concepts: XML Concepts: DTD Tutorial: DTD Tutorial: XML Schema Tutorial: XML Schema Tutorial: W3C’s XSL Site: W3C’s XSL Site: Other XML-related Notes: Other XML-related Notes:

Spring ICE 1341 – Programming Languages © In-Young Ko, Information and Communications University Midterm Term Project Design a structured programming language that includes the following language components Design a structured programming language that includes the following language components Type declaration statements for int, float, char, array Type declaration statements for int, float, char, array Operations: +, -, *, /, and, or, not Operations: +, -, *, /, and, or, not Assignment statement Assignment statement Conditional statement (if statement) Conditional statement (if statement) Loop (while statement) Loop (while statement) Program blocks (begin … end) Program blocks (begin … end) Develop an XML-based syntax of the language Develop an XML-based syntax of the language Write the grammar of the language in EBNF Write the grammar of the language in EBNF Write a sample program by using the language that you defined Write a sample program by using the language that you defined Display the sample program on MS Internet Explorer to validate its XML syntax Display the sample program on MS Internet Explorer to validate its XML syntax Explain the language design decisions such as application domains, and naming, binding, type compatibility, scoping rules Explain the language design decisions such as application domains, and naming, binding, type compatibility, scoping rules Due by April 14th