• Nenhum resultado encontrado

CDLP: Interactive Educational Software for a Course on Compiler Design Concepts

N/A
N/A
Protected

Academic year: 2017

Share "CDLP: Interactive Educational Software for a Course on Compiler Design Concepts "

Copied!
7
0
0

Texto

(1)

Available Online at www.ijecse.org ISSN- 2277-1956

CDLP: Interactive Educational Software for a Course

on Compiler Design Concepts

Narges Bathaeian 1 , Farzaneh Zareie 2, Susan Homaei-Pour 2 1 2 3 Department of Engineering

Bu-Ali Sina University Hamedan, Iran

Email-1 bathaeian@basu.ac.ir, 2 Farzaneh.Zareie@gmail.com, 3 Sousan.Homaei@yahoo.com

AbstractIn this paper, we present educational software named CDLP (Compiler Design Lab Package) to educate and

learn compiler design concepts. This tool is developed by Java programming language at Bu-Ali Sina University. CDLP is an interactive and visual system, suitable for doing and viewing exercises. In this system, problems and examples are defined by user as well as they are solved by user too. Though in each step of the solution, users receive a feedback from CDLP to warn their faults or guide them to the next step.

Keywords – Educational software, Interactive software, Compiler design, Scanner, Parser

I.INTRODUCTION

Traditionally, we think of a compiler as a program that translates a source language like FORTRAN into the assembly or machine language of some computer [1]. Conceptually, a compiler operates in phases, each of which transforms the source program from one representation to another. The first two phases called scanner and parser are forming the main parts of a course, usually called compiler design principles. This course is thought for undergraduate students who study computer science or software engineering.

Formal techniques to develop scanners and parsers are algorithmic. So during the course students learn to use these algorithms to build a scanner or a parser; but actually they just solve very simple examples by pen and paper, then at final of course, they use some “compiler compiler” tool [8,9] to do a pretty real sample. These tools, compiler compilers, are taking definition of the source language and building the compiler automatically. Therefore students never apply their knowledge to build a real compiler. Unlike “compiler compiler” tools, CDLP, as will be described, allows students to challenge their knowledge and examine their understandings of algorithms in real examples. In [7] has shown that how these tools can improve learning.

The next section 2 is a brief introduction to educational software. It defines different types of educational software and introduces a new definition of virtual lab. Section 3 describes related works to this package (CDLP). In section 4 the characteristics of CDLP is presented. Section 5 illustrates the use of CDLP by an example. Section 6 gives concluding remarks and discusses future works.

II.VIRTUAL LAB

Educational software may vary from a simple plain text to a complex graphical program that visualizes algorithms. Effectiveness of educational softwares are valued by their interactivity capabilities. Interactivity level means how much a learner can affect the contents of a learning environment. [3] assumed six levels of interactivity to classify educational software:

1. Just a medium of presentation

2. Users can choose from different forms of representations.

3. Users can vary the form of the representation, e.g. by scaling or rotating a diagram, 4. Users can manipulate the content, e.g. setting the parameters for a simulation.

5. A high level of interactivity can be achieved if the user cannot only manipulate the content, but can create new content as well.

(2)

2. Save exercise characteristics

In this paper, special type of high interactive educational software is our subject. We name that, virtual lab. Although virtual lab is a common name that refers to simulator of physics or chemical lab, but we emphasis on labs that simulate abstract concepts like mathematics or computer science.

Figure 1 illustrates a virtual lab. A virtual lab allows students to create individualized exercises and solutions. In addition students can get feedback on their solution. Virtual labs, just like real labs, provide tools for solving exercises. They use symbols to show abstract tools and concepts. Fortunately, most of abstract concepts in computer science, like stack, queue, automata and etc, have their own standard symbols.

Figure 1. Virtual lab illustration in 2 stages

III.RELATED WORKS

Although a large variety of tools have been developed to visualize computer science concepts but only a few of them are virtual labs as we defined in section 2.

[4] introduces an online educational tool to teach “data structures”. This tool allows students guess the solution of the problem. There are also similar tools for the “Algorithms Analysis and Design” course [5].

[6] introduces JFLAP. JFLAP incorporates many topics in “formal languages and automata theory”. This tool allows students to experiment with concepts and to receive immediate feedback on problem solving.

The more related software to our idea is [2]. This tool incorporates 2 algorithms of second phase of “compiler design phases”. It educates building LL(1) and LR(1) parsers through allowing student to define their exercises and examine themselves. Of course this tool doesn’t include support for other topics such as building the first phase (scanner), other algorithms of second phase (parser) and relating the scanner to parser.

IV.OVERVIEW OF CDLP

CDLP (Compiler Design Lab Package) is a virtual lab for experimenting with compiler design concepts. The first 2 phases of compiler design (scanner and parser) are covered in CDLP. As mentioned before, these 2 phases are heart of design. All 3 steps in building scanner (NFA, DFA and minimized DFA) as well as all 5 main algorithms of parsers (LL(1), LR(0), SLR(1), LALR(1) and LR(1)) are covered in CDLP. Fig.2 illustrates that every experiment in CDLP breaks in three stages.

1. Define exercise

2. Analyze the solution 1. Solve that

exercise

Virtual Lab Virtual Lab

(3)

CDLP: Interactive Educational Software for a Course on Compiler Design Concepts

Figure 2. Three stages of CDLP

Figure 2.a shows the first stage in which user defines the problem (characteristics of a programming language). Figure 2.b shows the second stage. User solves the problem (building the scanner and the parser) and receives immediate feedback on problem solving. This stage may repeat more and more to find the right solution.

Figure 2.c shows the third stage. User examines her solution by her defined inputs on it (defining an input file, examining it on scanner and then examining the scanner’s output file on built parser and watching steps of constructing parse tree).

The tools, provided by CDLP for problem solving, are dependent on chosen algorithm and phase. For example Figure 3.a shows the tools required for building a scanner. These icons are suitable for constructing a state-transition diagram. Figure 3.b shows the tools provided to build the LR(0) parser. More icons are added to pervious tools to construct sets of items needed to construct LR(0)’s state-transition diagram. Other tools such as tables and drawing panes are provided base on situation.

Figure 3. Tools provided to construct scanner (a) and LR(0) parser (b)

CDLP allows learners to solve problems step by step. For example to construct a scanner, after constructing a NFA, one can step through its conversion to a DFA, and then to a minimized DFA. Another example, to construct LL(1) parser, one can compute the first set and follow sets [1] of variables of the grammar and then build a parse table based on previous step.

V

.

A SIMPLE EXAMPLE

In the reminder of this paper, we use CDLP as running a simple example.

2. Analyze the built scanner and parser CDLP 1. Build scanner and parser

3. Message for guidance

2. Simulate the output

CDLP

(4)

First we should choose a part of a programming language. Arrays declaration in PASCAL language is our choice. Figure 4 shows this grammar.

Figure 4. A sample grammar (array declaration in Pascal)

In our sample grammar the set which is shown by “T” is the list of tokens. Each member of “T” is a token’s name. for example “_arr” is a name for keyword “array”. Other tokens: “_ob,” “_cb,” “_of,” “num,” “2dot” and “id” are names for “open bracket,” “close bracket,” “keyword of,” “number,” “..,” and “identifier” respectively. After choosing the grammar, then we must define tokens in the first phase of compiler design: Scanner. Usually, tokens are defined by regular expressions [1]. Figure 5 shows the list of defined tokens.

Figure 5. Defined tokens by regular expressions

Using CDLP we define these tokens and then build a scanner step by step. First we build a NFA, then convert that NFA to a DFA and then to a minimized DFA. CDLP’s feedback on each action can guide us to the right solution. Furthermore end of each step, CDLP’s message tell us our work is complete or not.

Figure 6 shows a part of NFA that is built for figure 5’s defined tokens.

Figure 6. Part of NFA of figure 5 (ep=null string)

(5)

CDLP: Interactive Educational Software for a Course on Compiler Design Concepts

Figure 7. A menu of CDLP to select kind of parser

To build a LR(1) parser, CDLP provides all tools include tools for constructing state diagram, finding follow sets, and filling up the parse table. Figure 8 shows these tools used for building LR(1) parser.

Figure 8. Tools needed to construct LR(1) parser (a:drawing panel, b:table of first and follow sets, parsing table)

(6)

At phase parser, they can run that output file of scanner phase in built parser and get a parse tree. Figure 9 illustrates these steps.

Figure 9. Steps of watching the result of scanner and parser

For example, when an input such as “array[1..10] of integer” is given to the built scanner, scanner produces a stream of tokens like “_arr _ob num 2dot num _cb _of id”. Then learner can give that output to the built parser and watch how this stream will be parsed by built parser. Figure 10 displays a sample parse tree. CDLP builds parse tree in steps, so users can follow it easily and understand the meaning of parse table.

a

(7)

CDLP: Interactive Educational Software for a Course on Compiler Design Concepts

c

Figure 10. Three steps of building a sample parse tree

VI.CONCLUSIONS AND FUTURE WORKS

In this paper, CDLP a tool for learning compiler design course is presented. CDLP is more than the one of algorithm visualization systems. It is full interactive system as allows students to experiment with concepts and to receive immediate feedback on problem solving; so we called it compiler virtual lab.

We will continue to develop CDLP into an extensive tool covering many of topics in a compiler design course including experimentation with other types of parsers, semantic analyzer, and intermediate code generation. We are also going to add discovery learning features to CDLP.

For downloading CDLP, please go to this web site:

http://profs.basu.ac.ir/bathaeian/index.php?L=free

VII.ACKNOWLEDGEMENT

We would like to thank Susan Bathaeian, Hosein Kamrani and all other people involved in the CDLP project.

VIII.REFERENCES

[1] A.V. Aho, R. Sethi & J.D. Ullman, "Compilers: Principles, Techniques and Tools", Addison-Wesley, 1986.

[2] S. A. Blythe, M. C. James, and S. H. Rodger, "LLparse and LRparse: Visual and Interactive Tools for Parsing" in Proceedings of the Twenty-Fifth SIGCSE Symposium on Computer Science Education Phoenix, Arizona, United States: ACM, pp. 208-212, 1994.

[3] M. A. Brandle, "GraphBench: Exploring the Limits of Complexity with Educational Software", Ph.D. Thesis, SWISS FEDERAL

INSTITUTE OF TECHNOLOGY, NO. 16392, 2006.

[4] D. J. Jarc, "Interactive Data Structure Visualizations", University of Maryland, 2004.

[5] A. Korhonen, "Visual Algorithm Simulation", Ph.D. Thesis, Helsinki University of Technology, 2003.

[6] S. H. Rodger, J. Lim, and S. Reading, "Increasing Interaction and Support in the Formal Languages and Automata Theory Course" in Proceedings of the 12th Annual SIGCSE Conference on Innovation and Technology in Computer Science Education Dundee, Scotland: ACM, pp. 58-62, 2007.

[7] A. Badre, C. Lewis, J. Stasko, "Empirically Evaluating the Use of Animations to Teach Algorithms", Proceedings of the 1994 IEEE Symposium on Visual Languages, pp. 48-54, 1994.

Referências

Documentos relacionados

nos exames parasitológicos de fezes positivos em uma população atendida entre janeiro a dezembro/2015 e janeiro a julho/2016 em um laboratório de análises clínicas do

Na dimensão 2, o objetivo consiste em desenvolver campanhas para conscientizar a comunidade acadêmica sobre a importância da promoção institucional de programas para

No Brasil, boa parte deste protestantismo (chamado posteriormente como protestantismo histórico principalmente após os desdobramentos dos movimentos pentecostais no

This study was carried out with students of the first and last year of Medicine and Literature courses and the main results showed that most students did not know that

Através do projeto de pesquisa “Modelo Tridimensional - Estudo dos Objetos Arquitetônicos e Urbanísticos” que está inserido na linha de pesquisa “Processos e Representação

Depressive and anxiety disorders as well as attention deficit hyperactivity disorder (ADHD) are regarded here as mental disorders with similar factors influencing the health

Retratamento Cirúrgico Quando o tratamento endodôntico não cirúrgico não funciona, ou não é viável, temos o tratamento endodôntico cirúrgico como última opção para manter o

He ends by stressing the importance of graph paper and pencils of several colours in higher grades as a means to make clear the relationships among several variables. The other