Week 13: Feb 3rd 2003, Abstract Syntax Trees, Error Recovery

From LRDE

The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

This page contains the log of the topics that were seen during the CompilationLecture for class EPITA 2005 (i.e., from Sept 2002 to June 2003). See also ThlLog2005.




See also http://www.lrde.epita.fr/~akim/compil/prog-lang-hist.pdf

  1. LL and arithmetics
  2. Solving conflicts with Bison
  3. Programming Language History
    1. Some Dates
    2. ENIAC and cables
    3. The baby and numbers
    4. Ferranti Pegasus and code
    5. IBM 704 and Fortran
    6. Algol and its familly
    7. COBOL

Warning: Display title "Week 13: Feb 3rd 2003, Abstract Syntax Trees, Error Recovery" overrides earlier display title "Week 12: Jan 27th 2003, Revisions & Programming Language History".

See also http://www.lrde.epita.fr/~akim/compil/t1-t2.pdf

  1. Presentation of the GNU Build System
    1. Autoconf
    2. Automake
    3. Gettext
    4. Argp
    5. Bison
    6. Flex
  2. The Tiger Compiler layout
    1. One module, one namespace
    2. Tasks
    3. Constraints over options (and their order)
  3. Other tools to know
    1. GDB
    2. dmalloc, Efence
    3. Valgrind
cat >stale-auto.c <<EOF
#include <stdio.h>

typedef struct list_s
{
  int val;
  struct list_s *next;
} list_t;


list_t *
list_new (int val, list_t *next)
{
  list_t res = { val, next };
  return &res;
}

void
list_print (const list_t *const list, FILE *out)
{
  if (list)
	 {
		fprintf (out, "%d\n", list->val);
		list_print (out, list->next);
	 }
}

int
main (void)
{
  list_print (list_new (2, list_new (1, list_new (0, NULL))),
				  stdout);
  return 0;
}
EOF
      1. Running Valgrind
      2. How it works
      3. gdb-attach
  1. Location tracking in Flex
  2. Error Recovery
    1. Using "error" with Yacc/Bison
    2. Generating dummy values
    3. The Error class
  3. Abstract Syntax Tree
    1. The Symbol class
    2. Parse Tree, Concrete Syntax
    3. Abstract Syntax Tree, Abstract Syntax
    4. Syntactic Sugar
      1. Curryfication: \lambda x y . e => \lambda x . (\lamda y e)
      2. Local variables: let x = e1 in e2 => (\lambda x e2) . e1
    5. "Core Languages"
    6. Tiger's case
      1. & and
      1. if then
      2. Declarations (Types and Functions recursivities)
      3. Beware of ( exp )
    1. Interferences with error messages, e.g., during type checking
    2. The case of preprocessors
  1. Communication between applications
    1. AST Generators
    2. ASN.1
Example DEFINITIONS ::= 
BEGIN
	 AddressType ::= SEQUENCE {
		  name				OCTET STRING,
		  number			 INTEGER,
		  street			 OCTET STRING,
		  apartNumber	  INTEGER OPTIONAL,
		  postOffice		OCTET STRING,
		  state			  OCTET STRING,
		  zipCode			INTEGER
	 }
END
    1. Tags used to avoid problems similar to matching (a*a*)
Example DEFINITIONS ::= 
BEGIN
	 Letter ::= SEQUENCE {
		  opening			OCTET STRING,
		  body				OCTET STRING,
		  closing			OCTET STRING,
		  receiverAddr	 [0] AddressType OPTIONAL,
		  senderAddr		[1] AddressType OPTIONAL
	 }
END
    1. SGML/XML
    2. CORBA
    3. ATerm
      1. ATerm Grammar (EBNF)
ATerm ::= AFun ["(" ATerms ")"] [Annotation]
{| class="wikitable"
|-
		  || "[" [ATerms] "]"		[Annotation]	
|}

ATerms ::= ATerm ("," ATerm)*
{| class="wikitable"
|-
AFun	::= AInt || Literal
|}

Annotation ::= "{" ATerms "}" 
      1. ATerm Examples
constants	:  abc
numerals	 : 42
literals	 : "asdf"
lists		 : [], [1, "abc" 2], [1, 2, [3, 4]]
functions	: f("a"), g(1,[])
annotations : f("a") {"remark"} 
    1. A threat to Free Software? The "GCC Introspector"
  1. Multimethods
  2. Visitors