Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mini-languages in Python

Tags:

python

dsl

I'm after creating a simple mini-language parser in Python, programming close to the problem domain and all that.

Anyway, I was wondering how the people on here would go around doing that - what are the preferred ways of doing this kind of thing in Python?

I'm not going to give specific details of what I'm after because at the moment I'm just investigating how easy this whole field is in Python.

like image 259
Reality Avatar asked Oct 10 '09 12:10

Reality


People also ask

What is mini language?

Mini is an attempt to create the simplest naturalistic language for human communication. With simple phonetics, inflectionless grammar, and a global vocabulary of exactly 1,000 words, Mini is ideal for use as an international auxiliary language.

Is Smalltalk better than Python?

Anecdotally and scientifically, Smalltalk is provably the most productive general-purpose programming language in the world. About 2.5X more productive than Python. About 2X more than Ruby. More than 3X as productive as JavaScript!

How many Python languages are there?

There are four main Python coding styles: imperative, functional, object-oriented, and procedural. (Some people combine imperative and functional coding styles while others view them as completely separate styles.)

What is native language in Python?

Since most modern OS are written in C, compilers/interpreters for modern high-level languages are also written in C. Python is not an exception - its most popular/"traditional" implementation is called CPython and is written in C.


1 Answers

Pyparsing is handy for writing "little languages". I gave a presentation at PyCon'06 on writing a simple adventure game engine, in which the language being parsed and interpreted was the game command set ("inventory", "take sword", "drop book", etc.). (Source code here.)

You can also find links to other pyparsing articles at the pyparsing wiki.

like image 163
PaulMcG Avatar answered Sep 19 '22 17:09

PaulMcG