-
Notifications
You must be signed in to change notification settings - Fork 156
Simple Calculator
Mathias edited this page Sep 14, 2010
·
6 revisions
The Simple Calculator example lives in the org.parboiled.examples.calculators package and is a set of two example parsers show-casing a simple recognizer and an actual calculator built with parboiled for Scala.
The first one, the SimpleCalculator0 is a simple recognizer for the following basic grammar, without any parser actions:
Expression ← Term ((‘+’ / ‘-’) Term)*
Term ← Factor ((‘*’ / ‘/’) Factor)*
Factor ← Number / Parens
Number ← Digit+
Parents ← ‘(’ expression ‘)’
Digit ← [0-9]
The SimpleCalculator1 examples adds parser actions that perform the actual calculations directly on the parsers value stack, without first creating an AST for the expression.
catch(err) {}
- Introduction
- ... Motivation
- ... Features
- ... Simple Java Example
- ... Simple Scala Example
- ... RegEx vs. parboiled vs. Parser Generators
- ... Projects using parboiled
- Installation
- Concepts
- ... The Big Picture
- ... The Rule Tree
- ... The Value Stack
- ... The Parse Tree
- ... AST Construction
- ... Parse Error Handling
- parboiled for Java
- ... Rule Construction in Java
- ... Parser Action Expressions
- ... Working with the Value Stack
- ... Action Variables
- ... Parser Extension in Detail
- ... Style Guide
- ... Java Examples
- ...... ABC Grammar
- ...... Calculators
- ...... Time Parser
- ...... Java Parser
- ...... Markdown processor
- parboiled for Scala
- ... Rule Construction in Scala
- ... Parser Actions in Scala
- ... Parser Testing in Scala
- ... Scala Examples
- ...... Simple Calculator
- ...... JSON Parser
- Advanced Topics
- ... Handling Whitespace
- ... Parsing Performance Tuning
- ... Indentation Based Grammars
- ... The ProfilingParseRunner
- ... Grammar and Parser Debugging
- ... Thread Safety
- Building parboiled
- parboiled-core Javadoc API
- parboiled-java Javadoc API
- parboiled-scala Scaladoc API
- Change Log
- Patch Policy