Created
May 30, 2012 09:59
-
-
Save island205/2835281 to your computer and use it in GitHub Desktop.
模板语言语法分析
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{Variable}} | |
{{#if conditions}} | |
BLOCK | |
{{/if}} | |
{{#if conditions}} | |
BLOCK | |
{{#elseif conditions}} | |
ELSEIF BLOCK | |
{{#else}} | |
ELSE BLOCK | |
{{/if}} | |
{{#each conditions as value index}} | |
BLOCK | |
{{/each}} | |
{{#! comments}} | |
/* description: Parses end executes mathematical expressions. */ | |
/* lexical grammar */ | |
%lex | |
%% | |
\s+ /* skip whitespace */ | |
<<EOF>> return 'EOF'; | |
/lex | |
/* operator associations and precedence */ | |
%start expressions | |
%% /* language grammar */ | |
expressions | |
: e EOF | |
{print($1); return $1;} | |
; | |
e | |
: e '+' e | |
{$$ = $1+$3;} | |
; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment