Build Your Own Lisp: Learn C and Build Your Own Programming Language by Daniel Holden
Author:Daniel Holden [Holden, Daniel]
Language: eng
Format: epub
Tags: C, LISP, Компиляция и интерпретация
ISBN: 9781501006623
Google: GSALogEACAAJ
Amazon: 1501006622
Goodreads: 24666409
Publisher: CreateSpace Independent Publishing Platform
Published: 2014-10-21T20:00:00+00:00
Builtin Functions
* * *
We can read in Q-Expressions but they are still useless. We need some way to manipulate them.
For this we can define some built-in operators to work on our list type. Choosing a concise set of these is important. If we implement a few fundamental operations then we can use these to define new operations without adding extra C code. There are a few ways to pick these fundamental operators but I've chosen a set that will allow us to do everything we need. They are defined as follows.
list Takes one or more arguments and returns a new Q-Expression containing the arguments
head Takes a Q-Expression and returns a Q-Expression with only of the first element
tail Takes a Q-Expression and returns a Q-Expression with the first element removed
join Takes one or more Q-Expressions and returns a Q-Expression of them conjoined together
eval Takes a Q-Expression and evaluates it as if it were a S-Expression
Like with our mathematical operators we should add these functions as possible valid symbols. Afterward we can go about trying to define their behaviour in a similar way to builtin_op.
mpca_lang(MPCA_LANG_DEFAULT, " \ number : /-?[0-9]+/ ; \ symbol : \"list\" | \"head\" | \"tail\" \ | \"join\" | \"eval\" | '+' | '-' | '*' | '/' ; \ sexpr : '(' <expr>* ')' ; \ qexpr : '{' <expr>* '}' ; \ expr : <number> | <symbol> | <sexpr> | <qexpr> ; \ lispy : /^/ <expr>* /$/ ; \ ", Number, Symbol, Sexpr, Qexpr, Expr, Lispy)
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(12570)
Hello! Python by Anthony Briggs(9914)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9796)
The Mikado Method by Ola Ellnestam Daniel Brolund(9777)
Dependency Injection in .NET by Mark Seemann(9337)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8296)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7763)
Grails in Action by Glen Smith Peter Ledbrook(7696)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7557)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7070)
Microservices with Go by Alexander Shuiskov(6831)
Practical Design Patterns for Java Developers by Miroslav Wengner(6750)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6695)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6413)
Angular Projects - Third Edition by Aristeidis Bampakos(6097)
The Art of Crafting User Stories by The Art of Crafting User Stories(5622)
NetSuite for Consultants - Second Edition by Peter Ries(5560)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5367)
Kotlin in Action by Dmitry Jemerov(5062)
