Skip to content

Commit

Permalink
Initial commit of implementation files and Readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
dloscutoff committed Apr 19, 2015
0 parents commit 3058cb8
Show file tree
Hide file tree
Showing 11 changed files with 2,870 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
__pycache__
*NOT for repos*
*DATED*
*OLD*
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Pip

Pip is an interpreted, imperative code-golf language.

### Usage

Pip is implemented in Python3. The main interpreter is the pip.py file. It should run on most systems with Py3 installed simply by invoking `pip.py` in the shell (you'll need to make the file executable first on *nix systems). Typical invocation patterns:

`pip.py [flags] path/to/codefile.pip [args]`
`pip.py -e 'code' [flags] [args]`
`pip.py` (interactive mode)

Execute `pip.py --help` for more detailed information.

### Why Pip?

Pip's main reason for existence is to be a golfing language that 1) is imperative, and 2) uses infix operators. I do enjoy the challenge of stack-based programming from time to time, but I find the imperative paradigm much easier to think in, and therefore better. In my very unscientific testing so far, Pip has attained golfing scores roughly similar to those of GolfScript.

### What does the name refer to?

[This fellow](http://en.wikipedia.org/wiki/Pip_(Great_Expectations)), of course.

Actually, the name "Pip" originated as a [recursive acronym](http://en.wikipedia.org/wiki/Recursive_acronym), though exactly what it stands for is open to debate. For some possibilities, see The Tao of Pip. The name was also chosen for its connotations of smallness.

Pip is **not** to be confused with [pip](http://en.wikipedia.org/wiki/Pip_(package_manager)).
11 changes: 11 additions & 0 deletions Tao of Pip.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Pip isn't Python.
Pip isn't Perl.
Pip isn't PHP.

What is Pip?

Pip is procedural.
Pip is portable.
Pip is precise.
Pip is pithy.
Pip is Pip!
29 changes: 29 additions & 0 deletions errors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

import sys

class FatalError(Exception):
"""Class for throwing fatal errors."""
pass

class ErrorReporter:
"""Class for reporting error messages."""
def __init__(self, warnings=False):
# The warnings parameter determines whether to print nonfatal
# errors to stderr or suppress them
self._warnings = warnings

def warn(self, *message):
"""Print a nonfatal error if warnings are turned on."""
# Covert built-in Pip types in the message to strings of their names
message = (str(item)[15:-2] if "ptypes" in str(item) else item
for item in message)
if self._warnings:
print(*message, file=sys.stderr)

def die(self, *message):
"""Print a fatal error and exit."""
# Covert built-in Pip types in the message to strings of their names
message = (str(item)[15:-2] if "ptypes" in str(item) else item
for item in message)
print(*message, file=sys.stderr)
raise FatalError()
Loading

0 comments on commit 3058cb8

Please sign in to comment.