Pages

syntax highlight, analytics

26 June 2013

Java parser

I wrote a parser (or rather a specification for a parser in the syntax of a parser-generator) for COOL, and I wondered if mature, popular languages actually use these things to generate their parsers.

I noticed that the PMD project makes use of a (modified) copy of the JavaCC parser-generator definition for the Java grammar. Inspection of that file reveals the initial 1997 timestamp by author Sriram Sankar. According to Advances in Software Engineering, “The Java 1.1 grammar was developed by Sriram Sankar at Sun Microsystems and a copy of this grammar can be found in the distribution”1. The syntax of JavaCC at a glance is similar to yacc, CUP, bison. In the PMD .jjt file, the familiar token declarations start around line 234, and the grammar starts at line 1122.

So it turns out that the parser for at least one popular, non-trivial grammar started (persists?) life in a .jjt file.

Update, 9 Sept 2013: Josh Haberman wrote an illuminating article on LL and LR parsers:
Despite this vast body of theoretical knowledge, few of the parsers that are in production systems today make use of any of this theory. Many opt instead for hand-written parsers that are not based on any formalism. [...] GCC moved away from their Bison-based parser to a handwritten recursive descent parser. The Ruby interpreter MRI may be one of the few remaining mainstream language implementations that does still use Bison (an LR-based tool) for parsing. 
[...] pure LL and LR parsers have proven to be largely inadequate for real-world use cases. Many grammars that you'd naturally write for real-world use cases are not LL or LR, as we will see. The two most popular LL and LR-based parsing tools (ANTLR and Bison, respectively) both extend the pure LL and LR algorithms in various ways, adding features such as operator precedence, syntactic/semantic predicates, optional backtracking, and generalized parsing.



1. Hankan Erdogmus, Oryal Tanir. Advances in Software Engineering. p. 426. Springer, 2002

04 November 2012

Impossible Ideas

As a codicil to Paul Graham's frighteningly ambitious startup ideas, I have started a list of impossible ideas that interest me personally.

  • ubiquitous, secure, painless (one-click) bitcoin payment
  • ubiquitous, effortless, anonymous, encrypted communication
  • painless, anonymous, decentralized internet access
  • effortless expense/receipt management
  • effortless information management / mind mapping

Working on an impossible task is like exercise. If that exercise produces something that is good enough, then you have something that is better than any existing similar product.

10 July 2012

You say priori, I say posteriori

Arguments like “but it works” or “it gets the job done” are tell-tale signs of someone happy at the lowest level of the technical hierarchy and your cue to just quietly back out of the debate. —DHH 
I bet you over-engineered your startup:
Of the three startups I've worked with, two of the three were ridiculously over-engineered monstrosities that were way over time budget. It was clear that the CIO/CTO wanted to do cool fun stuff and not build a marketable product.

The other was cobbled together with completely shit code, was constantly breaking on releases, and was glued together with perl scripts. They're now publicly traded. 

10 April 2012

Character-level diff in git gui

Per-character differences are often more usable than line-level differences.1 WinMerge has pretty decent character-scoped diffing:


...but git gui  defaults to line-level "unified diff":



To get word-level diff, you can specify:
--color-words --word-diff
...but I want something closer to character-level diff.

27 October 2011

Talk: Silicon Carbide and Body-Machine Interfaces

Here are my notes from Dr. Stephen E. Saddow's presentation, "Silicon Carbide Biomedical Technology for Bone Implants, Stents and Brain-Machine Interfaces".
Electrical Engineering Department
Department of Molecular Pharmacology and Physiology
University of South Florida
Abstract: Amorphous silicon carbide (SiC) has been used for several years as a non-biofouling coating in biomedical devices such as coronary stents and bone implants. However, up to recently, the biocompatibility of single crystal SiC, which presents appealing bio-sensing potentialities, has been in question. A comprehensive study of the biocompatibility of this wide band-gap semiconductor has been performed with extremely promising results which show the higher performance of SiC in bio-environments with respect to Si, the leading semiconductor, and introduce SiC into a unique class of materials that is both bio- and hemocompatible. 

Previous Posts


Creative Commons License   This work is licensed under a Creative Commons Attribution 3.0 Unported License.