Emacs for Aider: an External Learning System
Total Page:16
File Type:pdf, Size:1020Kb
Emacs For Aider: An External Learning System Jeremy (Ya-Yu) Hsieh B.Sc., University Of Northern British Columbia, 2003 Thesis Submitted In Partial Fulfillment Of The Requirements For The Degree Of Master of Science in Mathematical, Computer, And Physical Sciences (Computer Science) The University Of Northern British Columbia May 2006 © Jeremy (Ya-Yu) Hsieh, 2006 Library and Bibliothèque et 1^1 Archives Canada Archives Canada Published Heritage Direction du Branch Patrimoine de l'édition 395 Wellington Street 395, rue Wellington Ottawa ON K1A 0N4 Ottawa ON K1A 0N4 Canada Canada Your file Votre référence ISBN: 978-0-494-28361-5 Our file Notre référence ISBN: 978-0-494-28361-5 NOTICE: AVIS: The author has granted a non L'auteur a accordé une licence non exclusive exclusive license allowing Library permettant à la Bibliothèque et Archives and Archives Canada to reproduce,Canada de reproduire, publier, archiver, publish, archive, preserve, conserve,sauvegarder, conserver, transmettre au public communicate to the public by par télécommunication ou par l'Internet, prêter, telecommunication or on the Internet,distribuer et vendre des thèses partout dans loan, distribute and sell theses le monde, à des fins commerciales ou autres, worldwide, for commercial or non sur support microforme, papier, électronique commercial purposes, in microform,et/ou autres formats. paper, electronic and/or any other formats. The author retains copyright L'auteur conserve la propriété du droit d'auteur ownership and moral rights in et des droits moraux qui protège cette thèse. this thesis. Neither the thesis Ni la thèse ni des extraits substantiels de nor substantial extracts from it celle-ci ne doivent être imprimés ou autrement may be printed or otherwise reproduits sans son autorisation. reproduced without the author's permission. In compliance with the Canadian Conformément à la loi canadienne Privacy Act some supporting sur la protection de la vie privée, forms may have been removed quelques formulaires secondaires from this thesis. ont été enlevés de cette thèse. While these forms may be includedBien que ces formulaires in the document page count, aient inclus dans la pagination, their removal does not represent il n'y aura aucun contenu manquant. any loss of content from the thesis. Canada A bstract In this thesis, I observed and established communications between EMACS, the external lexical analyzers, and the parser. There are two versions of the lexical analyzers: internal and external. The internal lexical analyzer was implemented in the programming language of E macs -LISP. The core of the external lexical analyzer was implemented in Flex. For the parser, Bison and Flex were used. This thesis describes (1) details of each component; (2) comparisons of the difference between internal and external information processing; (3) experimental advantages and disadvantages of each version; (4) evaluations of the efficiencies based on running time, memory usage, features presentations, and other resources usage; (5) what needs to be done to achieve such communications; and (6) A ldor syntaxes and grammar. 11 Table of Contents Abstract il Table of Contents iii List of Tables v List of Figures vi Introduction 1 1.1 W hat is A ldor ? .......................................................................................... 2 1.1.1 Lexical Features of ALDOR.............................................................. 4 1.2 W hat is E m acs ? .......................................................................................... 9 1.3 Literature Review ........................................................................................... 10 1.4 Purpose of my W ork .................................................................................... 11 1.5 Emacs Concepts .............................................................................................. 12 1.6 Version D etails .............................................................................................. 17 The Internal Lexical Analyzer 18 2.1 Overview of Building the Internal Lexical A nalyzer .............................. 19 2.2 Method ...............................................................................................................20 2.3 Efficiency ........................................................................................................... 26 2.4 C o rre c tn ess ........................................................................................................ 27 2.5 Problems Encountered and their Solutions ...................................................27 2.6 Conclusion and Summary .............................................................................. 29 The External Lexical Analyzer 31 3.1 Overview of Building the External Lexical Analyzer .................................31 3.2 Method .............................................................................................................. 34 3.3 Communication or P ip e s ................................................................................. 40 3.4 Efficiency ........................................................................................................... 41 3.5 C o rre c tn ess ........................................................................................................42 3.6 Problems Encountered and their Solutions .................................................. 44 3.7 Conclusion and Summary ..............................................................................52 111 4 The Aldor Parser 53 4.1 Overview of Building the Parser ....................................................................54 4.2 Method .............................................................................................................. 55 4.3 C om m unication ................................................................................................. 64 4.4 Efficiency ...........................................................................................................66 4.5 C o rre c tn ess ........................................................................................................68 4.6 Problems Encountered and their Solutions ................................................ 68 4.7 Future W ork ........................................................................................................73 4.8 Conclusion and Summary ..............................................................................74 5 A ider M ode 76 5.1 Progress and M ethods .................................................................................... 77 5.2 Syntax-based Colouring .................................................................................78 5.3 Updating Algorithms for the ALDOR M ode ................................................ 79 5.4 F e a tu re s.............................................................................................................. 81 5.5 Efficiency ...........................................................................................................82 5.6 Problems Encountered and their Solutions ................................................ 83 5.7 Conclusion and Summary ..............................................................................83 6 Conclusions and Summary 84 6.1 Summary of my Research Tim eline ............................................................. 85 6.2 What can People Learn from my Work? ....................................................86 6.3 Comparison of Lexical Analyzers .................................................................86 6.4 Further Improvement and Future W ork .......................................................87 Bibliography 88 A A Lexical Structure for Aldor 92 A.l Lexical Structure ..............................................................................................92 A. 1.1 C haracters ...............................................................................................92 A. 1.2 The Escape C h a r a c te r ........................................................................ 93 A. 1.3 T okens ..................................................................................................... 93 A.2 Differences Between the Implemented Lexical Scanner and the A l dor Lexical Structure ..................................................................................... 96 B Context Free Grammars for Aldor 98 C Abstract Syntax for Aldor 112 D Codes for my Work 117 E UML Diagram of External Lexical Analyzer 118 F UML Diagram of Parser 120 IV List of Tables 1.1 Token Categories for ALDOR Tokens ...................................................... 5 1.2 E macs LISP and F lex Regular Expressions for ALDOR Tokens. 6 1.3 Emacs-LISP and F lex Regular Expressions for A ld o r Floating Point Tokens ...................................................................................................... 7 1.4 The Version Details of the Programs U sed ............................................ 16 5.1 The Colour Association Used by the A ld o r Mode ................................ 78 List of Figures 2.1 A Regular Expression to Match A ld o r Reserved W ords .............22 2.2 A Regular Expression to Match A ld o r String Tokens ...........................23 2.3 A Regular Expression to Match A ld o r Intermediate Tokens ......24 2.4 A Regular Expression to Match A l d o r Floating Point Literals Tokens 25 2.5 A Regular Expression to Match A ldor Pre-document Tokens .... 25 2.6 A ld o r Token Precedence