Paste: EBNF for Combinator Calculus

Author: yuuki
Mode: factor
Date: Sun, 30 Nov 2008 22:20:13
Plain Text |
! Copyright (C) 2008 Matthew Willis
! See http://factorcode.org/license.txt for BSD license.
USING: kernel peg.ebnf sequences sequences.lib strings ;

IN: lambda.ebnf

TUPLE: apply func arg ;
C: <apply> apply

TUPLE: def id term ;
C: <def> def

EBNF: parse-term
s           = ' '*

id          = [a-zA-Z]+             => [[ >string ]]
paren       = '(' term-list ')'     => [[ second ]]
term        = paren | id
sterm       = s term s              => [[ second ]]
term-list   = (sterm)+              => [[ [ <apply> ] reduce* ]]

def         = id s ':=' term-list   => [[ [ first ] [ fourth ] bi <def> ]]
stmt        = def | term-list
;EBNF

New Annotation

Summary:
Author:
Mode:
Body: