Created
May 25, 2012 13:00
-
-
Save fjolnir/2787998 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
%token keyword_nil | |
%token tLPAREN tRPAREN // () | |
%token tLBRACE tRBRACE // {} | |
%token tLBRACKET tRBRACKET // {} | |
%token tPIPE // | | |
%token tCOLON // : | |
%token tSEMICOLON // ; | |
%token tDOT // . | |
%token tCOMMA // , | |
%token tASSIGN // = | |
%token tNUMBER // <number> | |
%token tSTRING // Contents of a quoted string | |
%token tIDENTIFIER // An identifier, non quoted string matching [a-zA-Z0-9_]+ | |
%{ | |
%} | |
%% | |
program: | |
| expr | |
; | |
call: | |
expr tCOLON args tSEMICOLON | |
| expr tSEMICOLON | |
; | |
args: | |
expr tIDENTIFIER tCOLON args | |
| expr tCOLON args /* Never reduced */ | |
| expr /* never reduced */ | |
; | |
block: | |
tLBRACE argDefs tPIPE expr tRBRACE | |
| tLBRACE expr tRBRACE | |
; | |
argDefs: | |
argDef tIDENTIFIER tCOLON argDefs | |
| argDef tCOLON argDefs | |
| argDef | |
; | |
argDef: | |
tIDENTIFIER | |
varDef: | |
var tASSIGN expr | |
; | |
var: | |
tIDENTIFIER | |
; | |
expr: | |
var | |
| varDef | |
| block | |
| objAccess | |
| obj | |
| tLPAREN expr tRPAREN | |
| literal | |
| call | |
; | |
obj: | |
tLBRACKET tRBRACKET | |
| tLBRACKET objMembers tRBRACKET | |
; | |
objMembers: | |
| objMembers tCOMMA objMembers | |
| objMember | |
; | |
objMember: | |
tIDENTIFIER tASSIGN expr | |
; | |
objAccess: | |
var tDOT tIDENTIFIER | |
; | |
literal: | |
tNUMBER | |
| tSTRING | |
; | |
%% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment