Giter Club home page Giter Club logo

build-your-own-programming-language's Introduction

Build Your Own Programming Language

Build Your Own Programming Language

This is the code repository for Build Your Own Programming Language , published by Packt.

A programmer's guide to designing compilers, interpreters, and DSLs for solving modern computing problems

What is this book about?

The need for different types of computer languages is growing rapidly and developers prefer creating domain-specific languages for solving specific application domain problems. Building your own programming language has its advantages. It can be your antidote to the ever-increasing size and complexity of software. However, creating a custom language isn't easy.

This book covers the following exciting features:

  • Perform requirements analysis for the new language and design language syntax and semantics.
  • Write lexical and context-free grammar rules for common expressions and control structures.
  • Develop a scanner that reads source code and generate a parser that checks syntax.
  • Build key data structures in a compiler and use your compiler to build a syntax-coloring code editor.
  • Implement a bytecode interpreter and run bytecode generated by your compiler.
  • Write tree traversals that insert information into the syntax tree.
  • Implement garbage collection in your language.

If you feel this book is for you, get your copy today!

Instructions and Navigations

All of the code is organized into folders. For example, Chapter02.

The code will look like the following:

procedure main(argv)
    simple := simple()
    yyin := open(argv[1])
    while i := yylex() do
        write(yytext, ": ", i)
end

Following is what you need for this book: This book is for software developers interested in the idea of inventing their own language or developing a domain-specific language. Computer science students taking compiler construction courses will also find this book highly useful as a practical guide to language implementation to supplement more theoretical textbooks. Intermediate-level knowledge and experience working with a high-level language such as Java or the C++ language are expected to help you get the most out of this book.

With the following software and hardware list you can run all code files present in the book (Chapter 1-17).

Software and Hardware List

Chapter Software required OS required
3-16 Uflex, Jflex, Unicon, Java Windows, Mac OS X, and Linux (Any)

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. Click here to download it.

Code in Action

The Code in Action videos for this book can be viewed at https://bit.ly/3njc15D.

Related products

Get to Know the Author

Clinton L. Jeffery is Professor and Chair of the Department of Computer Science and Engineering at New Mexico Institute of Mining and Technology. He received his B.S. from the University of Washington, and M.S. and Ph.D. degrees from the University of Arizona, all in computer science. He has conducted research and written many books and papers on programming languages, program monitoring, debugging, graphics, virtual environments, and visualization. With colleagues, he invented the Unicon programming language, hosted on the Unicon website.

Download a free PDF

If you have already purchased a print or Kindle version of this book, you can get a DRM-free PDF version at no cost.
Simply click on the link to claim your free PDF.

https://packt.link/free-ebook/9781800204805

build-your-own-programming-language's People

Contributors

cjeffery avatar packt-itservice avatar packtutkarshr avatar solankikaran avatar stormmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

build-your-own-programming-language's Issues

Chapter 3 Java Issue

@cjeffery The method deEscape in the ch3 token.java class that we implement causes an infinite loop and the jvm runs out of memory. The issue is that the while loop checks sin.length but never updates it unless it goes into the if(c=='\\'). You may have been thinking that you would use the int i variable as a counter because it's never used.

I think there should be a sin = sin.substring(1); after the sout.append(c);.

That's what I put it and it fixed the issue.

Also which version of java are you using that has a static String.substring method? I am assuming it's meant to call sin.substring(...).

Chapters 5/6 unicon version of j0 parser does not run

In chapters 5 and 6, so far, when I run the unicon version of the j0 compiler using the hello.java file as input, I receive an error during the parse.

Here is the command-line I run on Ubuntu Linux 21.10 with KDE:

./j0 hello.java

and this is the error messages that I receive:

Run-time error 102
File j0gram.y; Line 30
numeric expected
offending value: tree_11
Traceback:
main(list_1 = ["hello.java"])
yyparse() from line 9 in j0.icn
action_21() from line 581 in j0gram.icn
{tree_11 = tree_14} from line 30 in j0gram.y

I even ran the compiler/parser in debug mode, but it did not give me any useful information.

It seems to be failing on lines 28/29 of the j0gram.y file:

VarDeclarator: IDENTIFIER | VarDeclarator '[' ']' {
$$=j0.node("VarDeclarator",1060,$1); };

The java version of the parser for j0 runs fine.

Does anyone have any ideas on how to fix this?

Can't Find UFlex in Unicon Installation

@cjeffery, first of all I'd like express my uttermost compliments for your book Build Your Own Programming Language — it's simply fantastic! And, I would like to add, it's one of the very few books on the subject which explores the topic in a truly pedagogical way for the non-academic reader, providing a good panoramic of the necessary steps to consider in approaching the task of designing a new programming language.

I was really glad when I discovered you opted to use Unicon as a language for the task at hand. I didn't know Unicon (nor Icon, for that matter) but as I keep reading on the book I can see why this was an excellent choice.

In "Ch.3 - Technical requirements" you wrote:

UFlex comes with Unicon and requires no separate installation.

I've download Unicon 13.2 for Windows, but I can't seem to find UFlex anywhere in the installation folder (searching the directory tree for a file named uflex doesn't match anything either).

The only tool that I could find was in the uni/unicon/ subfolder, a source file named unilex.icn which I managed to compile successfully, but the executable doesn't seem to provide any --help, so I'm not sure if that file is just part of Unicon compiler source or whether it's the same UFlex tool mentioned in the book.

Could you please help me find the UFlex tool mentioned in the book?


P.S.1 — I've found some typos and other errors I'd like to report. Can I use this repository Issues to do so? The online book at Packt doesn't mention any contact for reporting errata.

P.S.2 — Any chance you could enable Discussion in this repository? It would be useful to share readers experiences, ask questions, etc., and I'd love to leave a book review there too (Packt doesn't allow customers to leave books reviews).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.