magcius loves parsley
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% set amo_user = request.amo_user %} | |
{% if user.is_authenticated() %} | |
<li class="account"> | |
<a href="#" class="user" title="{{ amo_user.email }}"> | |
{{ amo_user.welcome_name }}</a> | |
{% if account_links %} | |
<ul> | |
{% for link in account_links %} | |
{% if not loop.last %} | |
<li><a href="{{ link.href }}">{{ link.text }}</a></li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git diff -M HEAD | |
M lisp/base.lisp | |
M lisp/float.lisp | |
M lisp/util.lisp | |
diff --git a/lisp/base.lisp b/lisp/base.lisp | |
index 3ba43b3..21f6fe5 100644 | |
--- a/lisp/base.lisp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from unittest import TestCase | |
from terml.twine import SourceSpan, Twine | |
class SourceSpanTests(TestCase): | |
def test_creation(self): | |
ss = SourceSpan("http://example.org/t", True, 1, 0, 1, 9) | |
self.assertEqual(ss, | |
SourceSpan("http://example.org/t", True, 1, 0, 1, 9)) | |
self.assertEqual(list(ss), ["http://example.org/t", True, 1, 0, 1, 9]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
materials = { "iron": {"hardness": 4, "organic": False}} |
Now that you are familiar with the basics of Parsley syntax, let's look at a more realistic example: a JSON parser.
The JSON spec on http://json.org/ describes the format, and we can adapt its description to a parser. We'll write the Parsley rules in the same order as the grammar rules in the right sidebar on the JSON site, starting with the top-level rule, 'object'.
object = token('{') members:m token('}') -> dict(m)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import txurntable | |
from twisted.internet import reactor | |
auth = "..." | |
userid = "..." | |
roomid = "..." | |
def turntableStart(bot): | |
def speak(data): | |
name = data['name'] |
OlderNewer