main
Matthew Butterick 8 years ago
parent a65a9b7652
commit b81c2eee91

@ -1,2 +1,31 @@
# pitfall
pitfall [![Build Status](https://travis-ci.org/mbutterick/pitfall.svg?branch=master)](https://travis-ci.org/mbutterick/pitfall)
-
Racket DSL for parsing & generating PDF files
Installation
-
`raco pkg install pitfall`
Update
-
`raco pkg update pitfall`
Documentation
-
http://docs.racket-lang.org/pitfall
License
-
MIT License
Copyright (c) 2017 Matthew Butterick
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@ -0,0 +1,6 @@
#lang info
(define collection 'multi)
(define deps '("base" "rackunit-lib"))
(define build-deps '("scribble-lib" "racket-doc"))
(define version "0.0")
(define pkg-authors '(mb))

@ -0,0 +1,3 @@
#lang racket/base
(require pitfall/parse)

@ -0,0 +1,6 @@
*~
\#*
.\#*
.DS_Store
compiled/
/doc/

@ -0,0 +1,40 @@
# adapted from
# https://github.com/greghendershott/travis-racket/blob/master/.travis.yml
# Thanks Greg!
language: c
sudo: false
env:
global:
- RACKET_DIR=~/racket
matrix:
# - RACKET_VERSION=6.0
# - RACKET_VERSION=6.1
# - RACKET_VERSION=6.2
- RACKET_VERSION=6.3
- RACKET_VERSION=6.4
- RACKET_VERSION=6.5
- RACKET_VERSION=6.6
- RACKET_VERSION=HEAD
# You may want to test against certain versions of Racket, without
# having them count against the overall success/failure.
matrix:
allow_failures:
#- env: RACKET_VERSION=HEAD
# Fast finish: Overall build result is determined as soon as any of
# its rows have failed, or, all of its rows that aren't allowed to
# fail have succeeded.
fast_finish: true
before_install:
- git clone https://github.com/mbutterick/travis-racket.git
- cat travis-racket/install-racket.sh | bash # pipe to bash not sh!
- export PATH="${RACKET_DIR}/bin:${PATH}" #install-racket.sh can't set for us
script:
- cd .. # Travis did a cd into the dir. Back up, for the next:
# don't rely on package server
- travis_retry raco pkg install --deps search-auto https://github.com/mbutterick/pitfall.git
- raco test -p pitfall

@ -0,0 +1,3 @@
#lang info
(define scribblings '(("scribblings/pitfall.scrbl" ())))

@ -0,0 +1,3 @@
#lang racket/base

@ -0,0 +1,27 @@
#lang br/quicklang
(require "parser.rkt" "tokenizer.rkt")
(provide (matching-identifiers-out #rx"pf-" (all-defined-out)))
(module+ reader (provide read-syntax))
(define (read-syntax src port)
(define parse-tree (parse (make-tokenizer src port)))
(strip-bindings
#`(module pitfall-parse-mod pitfall/parse
#,parse-tree)))
(define-macro (my-mb PARSE-TREE)
#'(#%module-begin PARSE-TREE))
(provide (rename-out [my-mb #%module-begin]))
(provide null)
(define-macro (pf-program ARG ...)
#'(list ARG ...))
(define (pf-name str)
(let* ([str (string-trim str "/" #:right? #f)]
[str (regexp-replace* #px"#(\\d\\d)" str (λ (m sub) (string (integer->char (string->number sub 16)))))])
(string->symbol str)))
(pf-name "B#45#20L")

@ -0,0 +1,4 @@
#lang brag
pf-program : (NULL | CHAR | BOOLEAN | INT | REAL | pf-name)*
pf-name : NAME

@ -0,0 +1,10 @@
#lang scribble/manual
@require[@for-label[pitfall
racket/base]]
@title{pitfall}
@author{mb}
@defmodule[pitfall]
Package Description Here

@ -0,0 +1,5 @@
#lang pitfall/parse
null
true
false

@ -0,0 +1,30 @@
#lang br
(require brag/support)
(provide make-tokenizer)
(define-lex-abbrev digit (char-set "0123456789"))
(define-lex-abbrev hex-digit (:or digit (char-set "ABCDEF")))
(define-lex-abbrev digits (:+ digit))
(define-lex-abbrev sign (:? (:or "+" "-")))
(define-lex-abbrev blackspace (:~ whitespace))
(define-lex-abbrev nonreg-char (:seq "#" hex-digit hex-digit))
(define (make-tokenizer src port)
(port-count-lines! port)
(lexer-file-path src)
(define lex-once
(lexer-srcloc
[(eof) eof]
[whitespace
(token 'WHITESPACE lexeme #:skip? #t)]
[(:or "true" "false") (token 'BOOLEAN (equal? lexeme "true"))]
[(:seq sign digits) (token 'INT (string->number lexeme))]
[(:seq sign (:or (:seq digits "." (:? digits))
(:seq "." digits)))
(token 'REAL (string->number lexeme))]
[(:seq "/" (:+ (:or nonreg-char blackspace)))
(token 'NAME lexeme)]
["null" (token 'NULL 'null)]
[any-char (token 'CHAR lexeme)]))
(λ () (lex-once port)))
Loading…
Cancel
Save