Package: neulang
NeulangCoding for humans.DescriptionNeulang is a natural language enabling layer embedded in Python. It takes scripts containing pseudocode inOrgformat and runs them.Why?As the easiest programming language for anyone to learn, Python is awesome.
But there's still that curve that continues to shut many out of the coding world.
People shouldn't have to learn another language to code, especially in this age of smart devices, IoT and AI.
Let's bring coding to the people, not the people to coding.
Oh, and I have a lot of pseudocode in Org format that I'd like to make executable.Installingpip install neulangor clone the latest version fromGitLab.FeaturesCommand line modeneu [options] --command="* neu command"Interactive modeneu [options] [-i]Exit with*exit*,*quit*orCTRL+dImportable from module as an object instancefrom neulang import Neulangn = Neulang()script = "* air_say 'hello world'"n.loads(script)n.eval()Run script filesneu [options] /path/to/script.neuRun a single node in a script fileneu [options] script.neu -o"s/org/path/as/regex/or/index"Import other Neulang modules from the command lineneu [options] -m"path/to/first/module.neu:another/module.neu"Python-style module access* include("neulang.natural.basics")via scriptn.load_module("neulang.natural.basics")via instanceTranspile Neu to Python source (requiresastor)n.to_py()via instanceneu script.neu --to-pyvia CLIAccess the patterns defined in a module scopen.get_patterns()via instanceneu script.neu --patternsvia CLIUsageNB: This is beta software.For the best experience, use a text editor which supports org-mode. Preferably Emacs as it is used for the project. A sibling project, the NAIC IDE, is also currently under development.Activate org-mode on a new buffer (ALT+x org-mode ENTER) and write a script as organized pseudocode.Modify your pseudocode so it adheres to the operations available intests/tests.neu. The following operational layers are currently available:RegularPython expressionnodes:* print("Hello world")A provisional subset of Python statement-oriented features are also reimplemented as callables to ease transition. These are all prefixed withx_:* x_setv('os', x_import('os'))ASTIR (Abstract Syntax Tree Intermediate Representation) nodes as a drop-in for statements and expressions (not all are implemented as yet). It is distinguished by keywords beginning withair_. The rest tends to, in most cases, correspond to the Python-native name of the operation (though not in this example):* air_setv** my_string** This is a string* air_call print my_stringNatural language nodes parsed via theMycroft Adaptintent parser:Theintent_partssection takes 1+ valid regular expressions which uses dict groups to enable parsing into an intent. For convenience, named groups can be denoted by double angles, eg.<<req_my_name>>expands to(?P<req_my_name>.+).Thebodysection is made of any of the layers, and also expands the named groups as individual name-bindings.NB: seetests.neufor example usage.Run your script:neu script.neuProvide feedback on your experience, bugs and suggestions for improvement.ExamplesThere is currently one example, a todo app. It usesflaskandSQLAlchemyand is based onthis Flask intro tutorial. The code is inexamples/flask_todo. To install and run (assuming Neu is already working):git cloneandcdinto the projectpip install -r examples/flask_todo/requirements.txtneu examples/flask_todo/todo.neuThis starts a Flask app which serves an API for manages todos. The todos are stored in a - memory based by default - SQLite database. To interact with it, go to another terminal and run using the also includedHTTPieapp (or your preferred HTTP client which supports the methods POST, GET, PUT and DELETE):http -f POST http://127.0.0.1:5000/api/v0/tasks name=first id=0 note='My first note'http GET http://127.0.0.1:5000/api/v0/tasks/0http -f PUT http://127.0.0.1:5000/api/v0/tasks/0 name=first id=0 note='Editing the note...'http -f POST http://127.0.0.1:5000/api/v0/tasks name=first id=0 note='Adding more things to do!'http GET http://127.0.0.1:5000/api/v0/taskshttp DELETE http://127.0.0.1:5000/api/v0/tasks/0Go check out the Neu code that makes it possible. There are 3 files:flask.neuwhich manages the Flask app,database.neuwhich manages the database modeling and transactions, andtodo.neuwhich creates the app and defines the API endpoints. Don't forget to open in an editor with org-mode support!Org-Mode PrimerOrg-mode is a rich plain-text system for keeping notes, planning projects and a variety of other organizational tasks. It uses a hierarchial tree structure denoted by stars which can be easily manipulated with keyboard shortcuts. Parts of the text can be folded to show only the general structure and parts currently being worked on.These core features are inherited by Neulang, which will in time make coding more a matter of organizing natural phrases/sentences which describe desired operations. Specifically, the org-mode features (and their Emacs bindings) which make Neulang easily manipulable are:Create a new nodeALT+ENTERMove a single node up/downALT+UP/DOWNIndent/deindent a single nodeALT+LEFT/RIGHTIndent/deindent a node and its childrenALT_SHIFT+LEFT/RIGHTCycle parent node foldingTABSeeThe Org Manual: Structure editingfor more.LicenseGNU AGPLv3+. SeeLICENSE.ContributingSeeCONTRIBUTING.Release NotesSeeCHANGELOG.To DoDocumentationImplement remaining core Python features in ASTMore...News and CommunityFor more information, follow theNeulang Devchannel (preview here). Also join the officialNeulang ChatonTelegramand/or the bridgedMatrixroom at#neulang:matrix.org.