Sunday, August 31, 2008

Sunday Development Log

Sunday:
  1. Neat: http://www.google.com/codesearch
  2. SymbolStorage maps Word Tokens to Identifiers.
  3. Flex maps strings to Word Tokens.
  4. Bison parses Word Tokens using a LALR engine.
  5. A way to convert "a_class.ToString().c_str()" to "a_class.ToString()" for use in sprintf()--statically allocate a fixed character buffer within ToString() and return a pointer to it. No memory management, no extra class member variables, no repeat allocation. The only catch--this technique only works for predictable string lengths. For example, sprintf()'ing an integer into a string--2^64 fits into a null-terminated string of 21 bytes.

    Unrestricted string lengths necessitate dynamic memory allocation.

    Google prohibits C++ streams (except for logging), which seems to rule out std::string--I haven't seen or thought of a way other than std::ostringstream.

Monday, August 25, 2008

Monday Development Log

Monday:
  1. Didn't do anything this evening.

Saturday, August 23, 2008

Sunday Development Log

Sunday:
  1. Jia Peng Fang's "Winter River"
  2. Began implementation of classes Expression, Node, and Identifier.
  3. object.ToString().c_str() it is--failed to find a clean way to implement ToString() without new/malloc.

Monday, August 18, 2008

Monday Development Log

Monday:
  1. C++ introduced references in 1983 (C lacks references--instead, C uses pointers to implement pass-by-reference).
  2. Compiling class SymbolStorage--on Tuesday I'll begin testing it thoroughly.
  3. const_cast removes or adds the const label to a variable.

Sunday, August 17, 2008

Sunday Development

Sunday:
  1. Google's C++ style guide demands fprintf() over streams. Current inconsistency results in code like this: (*a_sibling_iterator).first->ToString().c_str()--Token.ToString() returns std::string.
  2. Kasper Peeters' Tree(std::pair) might work as a syntax tree container class, but as a symbol storage container it fails to offer key-based retrieval through std::find(), even if nodes contain container std::pair. On a secondary note, it also seems to fail to support equality functor assignment at the time of declaration.
  3. Researching the Standard Template Library's Associative Containers for alternatives--std::map tests out acceptably.
  4. Schwarz Stein's "Rise To Heaven" from their album "New Vogue Children"

Saturday, August 16, 2008

Saturday Development

Saturday, picking up after six days off:
  1. Implementing class SymbolStorage with Kasper Peeters' Tree project.
  2. Researched Standard Template Library class (STL) std::pair (/usr/include/c++/4.2.3/bits/string) to hold Token/Identifier pairs.
  3. Installed VIM
  4. Annihilator's "Crystal Ann" from the album "Double Live Annihilation"

Sunday, August 10, 2008

Sunday Development Log

Sunday:
  1. Reviewed the Google C++ Style Guide for formatting, naming, and comment considerations.
  2. Adiemus' "Adiemus" from their album "Songs of Sanctuary"
  3. Installed Valgrind suite of profiling and debugging.
  4. Installed kcachegrind which provides "visual support for the cachegrind skin of the memory analyzer Valgrind."
  5. Ludovico Einaudi's "Passagio" from his album "Le Onde"
  6. Implemented ToString() using std::ostringstream code from http://bytes.com/forum/thread62153.html
  7. Very cool: this mimics Java's "public final static" class feature: "newl_parser::parser::token::NUMBER". Namespace "newl_parser" contains class "parser" which contains public struct "token", the public struct containing enumerated type "yyTokenType" which (finally) contains all token types (for example, NUMBER, IDENTIFIER, ASSIGN).

Saturday, August 09, 2008

Saturday Development Log

Saturday:
  1. inifile-->newl_parser
  2. inifileLexer-->newl_lexer
  3. inifile_driver-->newl_driver
  4. nm views symbols of object files
  5. To remedy error "multiple definition of `yyFlexLexer::yywrap()'", remove option %noyywrap--then manually redefine "int yyFlexLexer::yywrap() { return 1; }" in file lexer.ll. Flex defines yyFlexLexer::yywrap() in both %.cc and %.hh--the linker encounters multiple declarations if two objects (lexer.o and driver.o, for example, if driver.cc includes lexer.hh).
  6. Bond's "Duel" from the album "Born"
  7. Arvo Pärt's "An den Wassern zu Babel", from the album "Arbos"
  8. Yann Tiersen's "Le Moulin" from the album "Le Fabuleux Destin d'Amelie Poulain"
  9. parse() handles both char * (filename) and std::istream (stdin) depending on the signature of the call.
  10. Max Richter's "Sarajevo" from his album "Memoryhouse"
  11. Completed fully object-oriented Flex+Bison simple calculator.

Friday, August 08, 2008

Friday Development

Friday:
  1. Implementing Jan's suggested Bison/Flex C++ implementation that I discovered last night. Download example.tar.gz failed to contain files referenced by the Makefile: validate.cc, update-individual-policy.cc, combine-multiple-policies.cc. Commented-out references to them (targets "validate", "update-individual-policy", "combine-multiple-policies", "validate.o", "update-individual-policy.o", and "combine-multiple-policies.o") and modified target all to read "all: scanner.o inifile.o parser.o dump.o". I also commented out "COPTS= -m64 -mcpu=ultrasparc". It compiles.
  2. Why don't GNU projects Bison and Flex figure out how to get compatible on C++ object implementation? It's really awful, in my opinion--it could be so much better.
  3. Eluvium's "After Nature" from their album "Copia"
  4. Ludovico Einaudi's "Primavera" from their album "Divenire."
  5. Pachobel's Canon in WTF

Thursday, August 07, 2008

Thursday Development Log

Thursday:

  1. "I now understand why the Bison C++ example uses Flex in C stdio mode: because getting it to operate using C++ is nigh-on impossible." Link: http://ioctl.org/jan/bison/

Wednesday, August 06, 2008

Sunday, August 03, 2008

Sunday Development Log

Sunday:
  1. Finished reading the white paper "Recursive Make Considered Harmful"
  2. Consulted the Flex manual: http://flex.sourceforge.net/manual/
  3. Compiled small Flex program in anticipation of testing new non-recursive make harness.
  4. Discovered O'Reilly's online book "Managing Projects with GNU Make Managing Projects with GNU Make, Third Edition" at http://oreilly.com/catalog/9780596006105/book/index.csp , part of their Open Book Project.
  5. It seems the nonrecursive harness uses implicit compiles for all the C files it encounters.
  6. Getting my head wrapped around the targets and dependencies of the nonrecursive make harness.
  7. Successfully modified the nonrecursive make harness so it compiles GNU Flex code into a binary.
Compiling Bison into a binary using the nonrecursive make harness represents the next step.

With all this talk about nonrecursive make, one might get the wrong impression that I'm doing this solely to learn about it. In fact, I'm finishing up a summer project for my CSC-251 compiler class, which is why GNU Flex/Bison come into play.

Saturday, August 02, 2008

Saturday Development Log

Application development represents a game of inches.
  1. Configured PDF viewing
  2. Installed and configured Subversion client kdesvn
  3. Installed IDE kdevelop--profiling and memory leak tools look promising. Will stick with Kate for now.
  4. Configured Konsole colors, font
  5. Added directory test and source file test/full-test.n.
  6. Added Makefile stubs in trunk using white-paper "Recursive Make Considered Harmful" (http://www.xs4all.nl/~evbergen/nonrecursive-make.html) as a guide.
  7. Installed Adobe Flash: sudo apt-get install flashplugin-nonfree
  8. Installed Amarok: sudo apt-get install amarok
  9. Installed g++: sudo apt-get install g++
  10. Installed dlocate: sudo apt-get install dlocate (initialize before using each time with sudo update-dlocatedb)
  11. Installed libldap2-dev: sudo apt-get install libldap2-dev (and in doing so learned the value of finding which packages contain header files via http://packages.debian.org/)

Steam Locomotive

It's hard to say how much this has enriched my life. Thanks to Brian Lavender for sharing it on SacLUG. Screen captures courtesy KSnapshot (very intuitive).

Installation: sudo apt-get install sl

Images

The default ("sl"):



Note: The default, it travels across the screen from right to left, with animated smoke and wheels.

"-a An accident seems to happen. You’ll feel pity for people who cry for help.":


Note: the same as the original except it shows two engineers saying "HelpHelp!".

"-l shows little one.":


"-F It flies.":


Note: the same as the original "sl" but it moves from the lower-right to the upper-left.

Brilliant. From the man page:

NAME
sl - display animations aimed to correct users who accidentally enter sl instead of ls.

SYNOPSIS
sl [ -alFe ]

DESCRIPTION
sl Displays animations aimed to correct users who accidentally enter sl instead of ls. SL stands for Steam Locomotive.

OPTIONS
-a An accident seems to happen. You’ll feel pity for people who cry for help.

-l shows little one.

-F It flies.

-e Allow interrupt by Ctrl+C.

SEE ALSO
ls(1)

BUGS
It rarely shows contents of current directory.

AUTHOR
sl was written by Toyoda Masashi . This manual page was written by Brian Ristuccia and
Kenshi Muto for the Debian GNU/Linux system but may be used by others under the same license as sl itself.

Deleted My Task Manager

Playing with KUbuntu and I accidentally deleted my task manager. All the icons on the widget bar's task manager went away, and all the other widgets flowed left.

I re-added the task manager widget but it appeared on the extreme right, and there doesn't seem to be an easy way to rearrange them. :(

The solution: remove everything, then re-add every widget in the correct order.

A stiff penalty for an easy mistake.

Linux PDF Issues

Firefox failed to load a PDF I typed into the address bar.

After a bit of trial and error, I discovered the PDF Download add-on, which makes it all simpler when one clicks a link.

I first downloaded FoxIt PDF reader for Linux (binary) and told Firefox to use that to open PDFs. Unfortunately, it opens the ReaderLinux binary, not the PDF. And once I associated the file type with the binary, the Linux Firefox fails to provide an easy way to disassociate itself from that.

The solution: edit file ~/.mozilla/firefox/profile.default/mimeTypes.rdf, and delete the XML sections dealing with ReaderLinux. Restart Firefox. The next time you attempt to open a PDF, Firefox will prompt the user again for what to do.

The final solution? Associating Okular (/usr/lib/kde4/bin/okular) with PDF file types instead works great. And PDF Download add-on works great too.

Friday, August 01, 2008

Late Night Subversion

Recording for future use:
  1. Create a Subversion repository: ubuntu:~/src/csc-251$ svnadmin create ///home/user/.subversion-repository
  2. Import the initial file hierarchy: ubuntu:~/src/csc-251$ svn import newlc file:///home/user/.subversion-repository/newlc -m "Initial import"
  3. Create a branch: ubuntu:~/src/csc-251$ svn copy file:///home/user/.subversion-repository/newlc/trunk file:///home/user/.subversion-repository/newlc/branches/my-branch
  4. Checkout the project: ubuntu:~/src/csc-251$ mkdir newlc && cd newlc && svn checkout file:///home/user/.subversion-repository/newlc/trunk && cd trunk
Most notably, these commands seem to differ:
  • ubuntu:~$ svnadmin create ///home/user/.subversion-repository
  • ubuntu:~$ svnadmin create .subversion-repository
Why? It's a horrible user experience, in my opinion.

Under The Bridge

Walking home music today: Under the Bridge by RHCP:
Sometimes I feel
Like I dont have a partner
Sometimes I feel
Like my only friend
Is the city I live in
The city of angels
Lonely as I am
Together we cry

I drive on her streets
cause shes my companion
I walk through her hills
cause she knows who I am
She sees my good deeds
And she kisses me windy
I never worry
Now that is a lie

I dont ever want to feel
Like I did that day
Take me to the place I love
Take me all the way

Its hard to believe
That theres nobody out there
Its hard to believe
That Im all alone
At least I have her love
The city she loves me
Lonely as I am
Together we cry

I dont ever want to feel
Like I did that day
Take me to the place I love
Take me all the way

Under the bridge downtown
Is where I drew some blood
Under the bridge downtown
I could not get enough
Under the bridge downtown
Forgot about my love
Under the bridge downtown
I gave my life away
It's a great urban walking song. On my way to work on Wednesday, I noticed a man taking shelter under a bridge at Watt and Longview, which triggered this song in my head. Video.