Skip to content
Permalink
Browse files

Initial commit of implementation files and Readme.

  • Loading branch information
dloscutoff committed Apr 19, 2015
0 parents commit 3058cb802bf12f9ffa07b0c000f391f214729c41
Showing with 2,870 additions and 0 deletions.
  1. +4 −0 .gitignore
  2. +25 −0 README.md
  3. +11 −0 Tao of Pip.txt
  4. +29 −0 errors.py
  5. +1,525 −0 execution.py
  6. +243 −0 operators.py
  7. +270 −0 parsing.py
  8. +172 −0 pip.py
  9. +421 −0 ptypes.py
  10. +112 −0 scanning.py
  11. +58 −0 tokens.py
@@ -0,0 +1,4 @@
__pycache__
*NOT for repos*
*DATED*
*OLD*
@@ -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)).
@@ -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!
@@ -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()

0 comments on commit 3058cb8

Please sign in to comment.
You can’t perform that action at this time.