Skip to content

leavens/follow-grammar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

follow-grammar

A small Java project demonstrating how to "follow the grammar" in Java code. The grammar in question is a small expression language:

Expr ::= NumLitExpr | VarRefExpr | Expr - Expr | (Expr ? Expr : Expr)

There is an interface Expr that is the supertype of the classes: NumLitExpr, VarRefExpr, MinusExpr, and ConditionalExpr. Notice how the implementations of freeVars() and eval(Map<String,Integer>) both have a recursion pattern that follows the grammar.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages