University of New Brunswick, Faculty of Computer Science

CS4905 Introduction to Compiler Construction

JavaCC Simple Examples

These examples come with the JavaCC distribution (see Check out the README file for more details.

Simple1.jj Illustrating a simple JavaCC example that recognizes if curly braces { and } are paired properly.

Simple2.jj Similar to the Simple1 example, but allows white space between curly braces.

Simple3.jj Recognizes curly brace pairing, but adds tokens LBRACE and RBRACE, as well as counting how deeply nested the curly braces are.

NL_Xlator.jj Recognizes regular expressions and identifier (ID) tokens, as well as accounting for the priority of * over + operations.

IdList.jj Recognizes identifier (ID) tokens in a sequence allowing white space between IDs.