- Neat: http://www.google.com/codesearch
- SymbolStorage maps Word Tokens to Identifiers.
- Flex maps strings to Word Tokens.
- Bison parses Word Tokens using a LALR engine.
- 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.
Sunday, August 31, 2008
Sunday Development Log
Sunday:
Monday, August 25, 2008
Sunday, August 24, 2008
Hacker Test
A treasure trove of stuff I want to learn about:
http://linuxshellaccount.blogspot.com/2008/08/hacker-test-more-linux-and-unix-humor.html
http://linuxshellaccount.blogspot.com/2008/08/hacker-test-more-linux-and-unix-humor.html
Saturday, August 23, 2008
Sunday Development Log
Sunday:
- Jia Peng Fang's "Winter River"
- Began implementation of classes Expression, Node, and Identifier.
- 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:
- C++ introduced references in 1983 (C lacks references--instead, C uses pointers to implement pass-by-reference).
- Compiling class SymbolStorage--on Tuesday I'll begin testing it thoroughly.
- const_cast
removes or adds the const label to a variable.
Sunday, August 17, 2008
Sunday Development
Sunday:
- 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.
- 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.
- Researching the Standard Template Library's Associative Containers for alternatives--std::map tests out acceptably.
- 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:
- Implementing class SymbolStorage with Kasper Peeters' Tree project.
- Researched Standard Template Library class (STL) std::pair (/usr/include/c++/4.2.3/bits/string) to hold Token/Identifier pairs.
- Installed VIM
- Annihilator's "Crystal Ann" from the album "Double Live Annihilation"
Sunday, August 10, 2008
Sunday Development Log
Sunday:
- Reviewed the Google C++ Style Guide for formatting, naming, and comment considerations.
- Adiemus' "Adiemus" from their album "Songs of Sanctuary"
- Installed Valgrind suite of profiling and debugging.
- Installed kcachegrind which provides "visual support for the cachegrind skin of the memory analyzer Valgrind."
- Ludovico Einaudi's "Passagio" from his album "Le Onde"
- Implemented ToString() using std::ostringstream code from http://bytes.com/forum/thread62153.html
- 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:
- inifile-->newl_parser
- inifileLexer-->newl_lexer
- inifile_driver-->newl_driver
- nm views symbols of object files
- 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).
- Bond's "Duel" from the album "Born"
- Arvo Pärt's "An den Wassern zu Babel", from the album "Arbos"
- Yann Tiersen's "Le Moulin" from the album "Le Fabuleux Destin d'Amelie Poulain"
- parse() handles both char * (filename) and std::istream (stdin) depending on the signature of the call.
- Max Richter's "Sarajevo" from his album "Memoryhouse"
- Completed fully object-oriented Flex+Bison simple calculator.
Friday, August 08, 2008
Friday Development
Friday:
- 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.
- 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.
- Eluvium's "After Nature" from their album "Copia"
- Ludovico Einaudi's "Primavera" from their album "Divenire."
- Pachobel's Canon in WTF
Thursday, August 07, 2008
Thursday Development Log
Thursday:
- "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
Wednesday Development Log
Wednesday:
- Refreshed my memory of the Bison manual's section on generating a C++ scanner: http://www.gnu.org/software/bison/manual/html_mono/bison.html#C_002b_002b-Language-Interface
- Referenced Google Style C++ Guide: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Conditionals
Sunday, August 03, 2008
Sunday Development Log
Sunday:
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.
- Finished reading the white paper "Recursive Make Considered Harmful"
- Consulted the Flex manual: http://flex.sourceforge.net/manual/
- Compiled small Flex program in anticipation of testing new non-recursive make harness.
- 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.
- It seems the nonrecursive harness uses implicit compiles for all the C files it encounters.
- Getting my head wrapped around the targets and dependencies of the nonrecursive make harness.
- Successfully modified the nonrecursive make harness so it compiles GNU Flex code into a binary.
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.
- Configured PDF viewing
- Installed and configured Subversion client kdesvn
- Installed IDE kdevelop--profiling and memory leak tools look promising. Will stick with Kate for now.
- Configured Konsole colors, font
- Added directory test and source file test/full-test.n.
- Added Makefile stubs in trunk using white-paper "Recursive Make Considered Harmful" (http://www.xs4all.nl/~evbergen/nonrecursive-make.html) as a guide.
- Installed Adobe Flash: sudo apt-get install flashplugin-nonfree
- Installed Amarok: sudo apt-get install amarok
- Installed g++: sudo apt-get install g++
- Installed dlocate: sudo apt-get install dlocate (initialize before using each time with sudo update-dlocatedb)
- 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:
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 Mutofor 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.
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.
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:
- Create a Subversion repository: ubuntu:~/src/csc-251$ svnadmin create ///home/user/.subversion-repository
- Import the initial file hierarchy: ubuntu:~/src/csc-251$ svn import newlc file:///home/user/.subversion-repository/newlc -m "Initial import"
- 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
- Checkout the project: ubuntu:~/src/csc-251$ mkdir newlc && cd newlc && svn checkout file:///home/user/.subversion-repository/newlc/trunk && cd trunk
- ubuntu:~$ svnadmin create ///home/user/.subversion-repository
- ubuntu:~$ svnadmin create .subversion-repository
Under The Bridge
Walking home music today: Under the Bridge by RHCP:
Sometimes I feelIt'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.
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
Subscribe to:
Posts (Atom)
Blog Archive
-
▼
2008
(154)
-
▼
August
(19)
- Sunday Development Log
- Monday Development Log
- Hacker Test
- Sunday Development Log
- Monday Development Log
- Sunday Development
- Saturday Development
- Sunday Development Log
- Saturday Development Log
- Friday Development
- Thursday Development Log
- Wednesday Development Log
- Sunday Development Log
- Saturday Development Log
- Steam Locomotive
- Deleted My Task Manager
- Linux PDF Issues
- Late Night Subversion
- Under The Bridge
-
▼
August
(19)