Basil

Contents:
Home
Synopsis
Config file format
Grammar file format
Symbol attributes
Getting started
Visitors
Simulator
Examples
Download

Examples

The table below contains links to several example grammars.

Example Grammar Log Simulator
Input Trace Tree
basil rules-01 log-01 input-01 trace-01 tree-01
if else rules-02 log-02 input-02 trace-02 tree-02
expression rules-03 log-03 input-03 trace-03 tree-03
expression with single rules bypassed log-04 trace-04 tree-04
expression with priorities rules-05 log-05 trace-05 tree-05
C++ object declaration (simplified) rules-06 log-06 input-06 trace-06 tree-06
C++ object and function declaration (simplified) rules-07 log-07 input-07 trace-07 tree-07
C++ template-id with type and non-type arguments rules-08 log-08 input-08 trace-08 tree-08
A typical mistake in C++ is to write '>>' instead of '> >' to terminate a nested template-id. basil can recover very easily from such a mistake. For example, let's run basilsim with the log file log-08 and give it the input
# A <B <C>> 
IDENT LT IDENT LT IDENT RSHIFT
The recover strategy 'r:[GT,GT]:RSHIFT' will replace '>>' with '> >'. The recover message is
error.txt:3:1: Syntax error before '{end of file}'
error.txt:2:25: Replacing 'RSHIFT' with 'GT GT'
This would be just one of several recover strategies in a C++ parser.