Goto page 1, 2, 3, 4  Next
Lex & Yacc
Posted by lionel319 @ Wed 20 Aug, 08, 10:57AM under Work

 

This is getting uglier and uglier.

It seems like this thing is more complicated that I though ( and of course, with complication comes more powderful :p)


The previous link was too hard to read. I really need something which is easier to read and easily understandable in its explanation. And i believe here's one which does better job in this. [here]







Here's the brief explanation on Lex & Yacc:-



Figure 1: Compilation Sequence

You code patterns and input them to lex. It will read your patterns and generate C code for a lexical analyzer or scanner. The lexical analyzer matches strings in the input, based on your patterns, and converts the strings to tokens. Tokens are numerical representations of strings, and simplify processing. This is illustrated in Figure 1.

When the lexical analyzer finds identifiers in the input stream it enters them in a symbol table. The symbol table may also contain other information such as data type (integer or real) and location of the variable in memory. All subsequent references to identifiers refer to the appropriate symbol table index.

You code a grammar and input it to yacc. Yacc will read your grammar and generate C code for a syntax analyzer or parser. The syntax analyzer uses grammar rules that allow it to analyze tokens from the lexical analyzer and create a syntax tree. The syntax tree imposes a hierarchical structure on the tokens. For example, operator precedence and associativity are apparent in the syntax tree. The next step, code generation, does a depth-first walk of the syntax tree to generate code. Some compilers produce machine code, while others, as shown above, output assembly language.


Figure 2: Building a Compiler with Lex & Yacc

Figure 2 illustrates the file naming conventions used by lex and yacc. We’ll assume our goal is to write a BASIC compiler. First, we need to specify all pattern matching rules for lex (bas.l) and grammar rules for yacc (bas.y). Commands to create our compiler, bas.exe, are listed below:

yacc -d bas.y                   # create y.tab.h, y.tab.c
lex bas.l # create lex.yy.c
cc lex.yy.c y.tab.c -obas.exe # compile/link

Yacc reads the grammar descriptions in bas.y and generates a syntax analyzer (parser), that includes function yyparse, in file y.tab.c. Included in file bas.y are token declarations. The -d option causes yacc to generate definitions for tokens and place them in file y.tab.h. Lex reads the pattern descriptions in bas.l, includes file y.tab.h, and generates a lexical analyzer, function yylex, in file lex.yy.c.

Finally, the lexer and parser are compiled and linked together to form the executable, bas.exe. From main, we call yyparse to run the compiler. Function yyparse automatically calls yylex to obtain each token.









Blurrrrrrr ~~~~~~~~~~~~~~~~~

 

 

 

 

 

 

3 Roar(s) | Static Link | Rated:
A Whole New Perspective
Posted by lionel319 @ Tue 19 Aug, 08, 05:03PM under Work


Have been long rotten in my 'comfort rotten zone' , and it's hard to get my feet back into challanges.

Lately, I've been juggling around with lotsa new stuff, mainly, doing my best to pick up C++.

It's a whole new architecture. Something which is quite different from what I used to be used to (in PERL).

It's interesting to find back the once-long-lost feeling of being a student again. Brings back those memories when I just joined this company, and how tiny puny I was, seeking for all sorts of data to feed the hunger of my curiosity. It just makes me feel once again humble, energetic, and powderful.

Anyway, just to put up some links that I've got online, so that I can refer back to this page when I need to refer to them in the future.


1.Teach Yourself C++ in 21 Days
- all the teach yourself in 21days series are my favorites when starting to endeavor in a new area.

2. LEX & YACC
- a program that reads the hierarchical structure of a program, splits it into token, and generate a program that does that.
- this is used to read the verilog netlist, split it up into pieces, and later on, generate a C++ program to does all the above mentioned task.


Ok, That's all for the break. Time to get back to work again ......

 

Work ~~~~~ Work ~~~~~ - *Orc tone*


DELL's Studio Hybrid Desktop
Posted by lionel319 @ Tue 19 Aug, 08, 03:05PM under Work



Got to know this from HongKiat.

Nice ...... Stylish ............ and COOL !!!!!

 

 

And most importantly, which is the part i like most, is that ......

...it uses energy-efficient Intel®  CoreTM 2 Duo Mobile Processors, so you can enjoy its power while helping to preserve the planet......

 

 

Check out more from the official site.




 

 

Writing MasterMind in PERL
Posted by lionel319 @ Wed 23 Jul, 08, 01:52PM under Work


Someone suggested this, and I thought it is a very interesting challenge (not that it is hard) and nice program to write, and so, this will be my next hobby on my sleeve.

 

 

 

The only thing I couldn't decide at is what scoring system to use. Should I base the scoring system just on the number of tries? Or should I be using the time used? Or both?

 

Well, after a couple of search thru google, I finally reached this page.

 

Nice. the next thing will be the writing.

 

I'll post up the progress periodically if time allows. Stay tune ;) 

Ascii Art
Posted by lionel319 @ Fri 20 Jun, 08, 06:53PM under Work



A Very Nice "ASCII Art" website here.

Try it. You'll love it ;)

 

I did :)

 




A very Cool site To create your own Favicon
Posted by lionel319 @ Mon 09 Jun, 08, 03:41PM under Work



http://www.favicon.cc/



Very very interesting :)

For more information on how to put a favicon on your website, read more on it here.


Anyway, here's a simple one that I've made. :p

comments? :p


 

 

.... and did you notice that my http://lionel.textmalaysia.com has a new favicon? :P

 

... and want impress your girl friend by doing an animated gif favicon?
Here's a good site to create animated gif.
http://www.gifninja.com/CreateAGif.aspx

Automating ftp using Perl
Posted by lionel319 @ Wed 14 May, 08, 02:03PM under Work



Ever experienced the pain of  doing a put / get for each and every file / folder one by one when you want to transfer stuff across network? Well, worry no more. Here's something simple that you can do to automate the File Transferring Protocol process quick and easy, All you need is a perl module call Net::FTP.




#!/apps/perl/bin/perl -w

use Net::FTP;

$host = 'www.javtalk.com';
$username = 'adrian';
$password = 'mutumbo';

$ftp = Net::FTP->new($host, Debug=>0) || die "Can't connect to $hostn";
$ftp->login($username, $password) || die "Can't loginn";


### To get (download) a file from the server, use the get() command
### To put (upload) a file to the server, use the put() command

$ftp->get( "water.avi" ) ||  die "Can't GET.  $ftp->messagen";



Have fun playing with PERL
^_^



1 Roar(s) | Static Link | Rated:
Scheduling tasks on Linux using crontab
Posted by lionel319 @ Tue 13 May, 08, 05:12PM under Work



Have been hearing all about cronjobs crontab crond cron crom crom crom crom ~~~~~~ everyday, but think is the first time I really look deep into it.



A detail explanation can be found here.


Still, after reading it, I found it kinda not that flexible, at least not to the extend of what I was trying to achieve. Decided to might as well write my own simple cron job.


#!/apps/perl/bin/perl

while (1)
{
   # Do anything you want over here.
   # bla bla bla
  

   sleep( 86400);   # Repeat task every day
} # while
 



Yeah. I know it is cheap :P
who cares, so long it gets the job done
;)



5 Roar(s) | Static Link | Rated:
How To Get Website Content Using Perl
Posted by lionel319 @ Mon 05 May, 08, 04:50PM under Work



How To Get Website Content Using Perl ?

This has been troubling me for many many years.


It is very ...... seriously VERY EASY once you get to see the solution :P






First of all, you need the LWP module.
Can get it from http://search.cpan.org.
...... and here it goes:-








HAhahahahahaha :D
Easy ? :P


Well, if you are working behind a firewall, then too bad.
But if your firewall has a proxy, and you have a proxy, now this is where it gets interesting :p
There's still chance that you 'might' get lucky :p

Add this. It might work:-







Now, you can automate a program and download all the porn movies from work :P




 

Awesome Highlighter For Website
Posted by lionel319 @ Thu 13 Mar, 08, 09:43AM under Work




Wow ......
This is cool.

Ever have the intention to share a website with friend, but would like to highlight an important section of it to emphasis your point to them? Well, here's the solution.



The Awesome Highlighter allows you to highlight text in a webpage so that when you send a link you can be certain the recipient will know why. .....[as quoted from http://www.awesomehighlighter.com]


Try it. It's cool :)

Thanks HongKiat for sharing the finding.



Goto page 1, 2, 3, 4  Next
Search

Back to TextMalaysia Home
TextMalaysia.com is Powered by TinyMCE

Subscribe to this blog
RSS Feed for lionel.textmalaysia.com
Categories
Archive







© TextMalaysia is a free blogging service powered by WSATP