Showing posts with label compiler. Show all posts
Showing posts with label compiler. Show all posts

Monday, May 30, 2011

OMCC Presentation coming soon

Only one day left for the presentation, the latex Beamer software helped me for the first time to produce a PDF for the presentation. It is quite uncommon but very interesting to use LaTeX for a presentation. The result seems quite professional and only a few will tell it is LaTeX.

Today I will do one last rehearsal to prepare the presentation. It will take place in the room called Donald Knuth which is nice due to the contribution of Knuth to the LR parsing in 1965.

The last week I have been working only in the presentation and I did some reading again of the literature in order to have fresh all the concepts of compilers in case tricky questions come up by the opponent.

After a remarkable progress with the grammar with about 92% of the test suite working, OMCC is getting ready to be incorporated into the OMC compiler for OpenModelica.

Thursday, May 19, 2011

Final optimizations

I have increase the performance of my parser by simplifying the lexer and the parser. After I took out the recursion lexing and parsing one token at the time was easier.

My examiner wants me to implement an external C function to improve the speed of the lexer but the lexer is not my concern now. The time that the parser takes is considerable long, compared to the lexer.

More test will be performed over this weekend at the same time I keep growing the grammar which now only fails in 98 out of 568 cases in the grammar.

Monday, May 16, 2011

Presentation for the thesis scheduled

The time has come to present my thesis.

I have 2 weeks to prepare a good presentation and make good use of the software I produced.

However some improvements are required for the lexer to improve the performance.

The time for the presentation will be the 31st May 2011 15.15

Now is time to prepare an awesome presentation!!

Tuesday, May 10, 2011

My parser can parse itself

Finally after several months of hard work, I have archive the OMCC parser generator for MetaModelica and Modelica grammar. It is still a subset but it is working pretty fine.

The grammar for modelica file is about 700 lines of code. The files generated even more. In the last test it took around 6 seconds to parse all the file. This is quite big but it was running in debug mode. It means that some other optimizations should be made before the end of the thesis.

A new version of the draft will be released soon. So I hope I can post here the day of the presentation very soon when I talk with my examiner.

this was the last result of the test


***************-ACCEPTED-***************

SUCCEED - (AST)
args:ParserModelica.mo
Total time:6.113409437

Friday, May 6, 2011

draft 1 delivered

I just finished the first draft of the thesis, now it is under my supervisors review. However, the testing set for a subset of the Modelica grammmar wont be enough for the examiner, so I am currently working on extending the grammar for the parser while waiting for comments over the draft 1.

Tuesday, April 12, 2011

OMCC with error handling

I have been working on the thesis very hard lately, so far I have
accomplished this:

* Lexer and Parser
* Lexer and Parser Generator
* Error Handling

The last part is now working like this:

It uses error recovery to detect more errors, but it always fails at the end. Right now it only recovers from the action ERASE token, however if there are tokens with errors nearby it will stop parsing.

From the papers I read, I have this primary error handling techniques (single correction) which could be insert, replace or erase. So far I have not implemented MERGE because my parser only understand tokens and has no idea about the semantic value of the tokens. I need to implement a table to look for the semantic value, also important for displaying the errors with the right String not with the Token NAME as now.

***ERRORS WERE FOUND AND COULD NOT RECOVER ***

Syntax Error near [TOKEN:T_DO 'do' from (line:3 col:18) until (line:3
col:20)], ERASE token
Syntax Error near [TOKEN:T_ADD '+' from (line:4 col:13) until (line:4
col:14)], INSERT token {T_INTCONST or T_IDENT}
Syntax Error near [TOKEN:T_ADD '+' from (line:4 col:13) until (line:4
col:14)], REPLACE token with {T_LPAREN}
Syntax Error near [TOKEN:T_ADD '+' from (line:4 col:13) until (line:4
col:14)], ERASE token
Syntax Error near [TOKEN:T_IDENT 'y' from (line:8 col:5) until (line:8
col:6)], INSERT token {T_THEN}

program file:

1/* this is while test of comment */
2read x y z w;
3while x <> 99 do do
4 ans := (x++1) - (y/3);
5 write ans;
6 read x, y;
7 if x = 10
8 y := 234;
9 endif
10end


My thesis is getting close to the end, I hope it can be completed by the end of this month.

Friday, March 25, 2011

New omc-parser code project

I recently opened a google code project to handle all the source files of this master's thesis.

The link is here:

http://code.google.com/p/omc-parser/

Command-line access:

Use this command to anonymously check out the latest project source code:
# Non-members may check out a read-only working copy anonymously over HTTP.
svn checkout http://omc-parser.googlecode.com/svn/trunk/ omc-parser-read-only


It is a good place to keep my code safe and also to report all the issues that I get during the development.

I have just setup a development environment in Linux and I want to be able to switch and keep updated all my source code between both operative systems.

Soon I will write an article about software configuration management for students that are developing a thesis, and my experience with this website will definitely help.

Wednesday, March 23, 2011

Tables generator ready

Now my work consist on build part of the code automatically from the Flex and Bison code generated in C.

In order to build this it is necessary to read the lexer.c and parser.c file and generate the LexTable.mo ParseTable.mo that contains the arrays used for the automata machine, and the LexCode.mo and ParseCode.mo used for the actions after a token is found for lexer and a shift reduce rule to build the AST for the parser. The files Token.mo needs to be rebuild also from the parser.c code.

For making this machine customized for any language, it is necessary to link the generated files together with the main files Lexer.mo and Parser.mo, so those files will be generated also with a sufix which will identify the machine.

For my thesis, the exercise 10 and exercise 4 are the examples I am using for testing the machine, so the machines will contain all these files with the sufix 10 and 4 respectively.

Some code cleaning is still necessary to do, but this does not affect the current work, it will be complemented later after the Error Handled is improved in the parser.

Thursday, March 10, 2011

The Parser is now Parsing

After dealing with the C code generated by BISON, with more than 15 arrays and crazy GOTO statements, I have managed to create the first parser in MetaModelica that parses the exercise 10 of the MetaModelica examples (for those who have read the MetaModelica Document).

For the rest of the mortals, what I have achieve is to make the code of a program to be recognized by another program (Compiler Parser). However there are more stuff to do before this task is complete, including the generation of the AST, error handling and cleaning of the code.

It is now week 10 and hopefully 10 weeks more to go and finish this project. Next activities will be to focus on the MetaModelica code generation based on the Flex and Bison files.

Tuesday, December 28, 2010

Starting the reading

This year is almost gone, and I have in mind to start fully productive in January with my Master Thesis at Linköping University for the master program in Computer Science, so I decided to spend the most of this december in reading some interesting references for my master thesis.

First, I have to start catching up with all the theory of Compilers, so I have started reading the first 4 chapters of the book Compilers Principles, Techniques, and Tools

I also have a lot to read from the book Principles of Object Oriented Modeling and simulation with modelica 2.1

One of my supervisors had a video conference with me today to explain me a bit more about the whole project open modelica and to clarify me a bit more about the PARCER that I will build for this project.

The idea is to improve the speed and the error detection in open modelica by replacing the current parcer ANTLR with a integrated parcer built in Modelica language.

Next meeting will be next week or better to say "next year" and I hope to be done with the reading.

My idea is to start the second week of January to design the structure of the parcer and learn the tool I will use to write the compiler parcer.