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
;;;; Recursive Descent Parser Generator | |
;;;; Copyright 2008 Peter Goodman, all rights reserved | |
(defun concatenate* (type &rest lst) | |
"Concatenate all cars within a tree." | |
(setf lst (remove nil lst)) | |
(if (null lst) | |
"" ; nothing to concatenate, return | |
(let ((a (car lst)) (d (cdr lst))) |
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
(defun-parser :html-attr | |
(no-capture (repeat 0 nil " ")) | |
(and (concat (repeat 0 nil (range #\a #\z)) | |
(and ":" (repeat 0 nil (concat (range #\a #\z))))) | |
(no-capture #\= #\") | |
(find-next #\") | |
(no-capture #\"))) | |
(defun-parser :html-attrs | |
(repeat 0 nil :html-attr)) |
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
(print (parse ':html "prefix text<div class=\"post\"><a name=\"comment-{$comment.comment_ID}\" id=\"comment-{$comment.comment_ID}\"></a>{$comment.content}<ul class=\"categories\">by <cond:if var=\"comment.comment_author_url\" neq=\"\"><a href=\"{$comment.comment_author_url}\" title=\"{$comment.comment_author}\">{$comment.comment_author}</a><cond:else />{$comment.comment_author}</cond:if> on {$comment.date} </ul></div>postfix text")) | |
;; what's generated: | |
("prefix text" (:HTML-TAG "" (:HTML-TAG-NAME "div") (:HTML-ATTRS (:HTML-ATTR "class" "post")) "") "" (:HTML-TAG "" (:HTML-TAG-NAME "a") (:HTML-ATTRS (:HTML-ATTR "name" "comment-{$comment.comment_ID}") (:HTML-ATTR "id" "comment-{$comment.comment_ID}")) "") "" (:HTML-TAG "/" (:HTML-TAG-NAME "a") (:HTML-ATTRS) "") "{$comment.content}" (:HTML-TAG "" (:HTML-TAG-NAME "ul") (:HTML-ATTRS (:HTML-ATTR "class" "categories")) "") "by " (:HTML-TAG "" (:HTML-TAG-NAME "cond:if") (:HTML-ATTRS (:HTML-ATTR "var" "comment.comment_author_url") (:HTML-ATTR "neq" "")) "") "" |
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
(defun-parser :html-attr | |
(no-capture (repeat 0 nil " ")) | |
(and (concat (repeat 0 nil (range #\a #\z)) | |
(and ":" (repeat 0 nil (concat (range #\a #\z))))) | |
(no-capture #\= #\") | |
(find-next #\") | |
(no-capture #\"))) | |
(defun-parser :html-attrs | |
(repeat 0 nil :html-attr)) |
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
("prefix text" | |
(:HTML-TAG | |
"" | |
(:HTML-TAG-NAME "div") | |
(:HTML-ATTRS | |
(:HTML-ATTR "class" "post")) | |
"") | |
"" | |
(:HTML-TAG | |
"" |
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
(print (parse ':html "prefix text<div class=\"post\"><a name=\"comment-{$comment.comment_ID}\" id=\"comment-{$comment.comment_ID}\"></a>{$comment.content}<ul class=\"categories\">by <cond:if var=\"comment.comment_author_url\" neq=\"\"><a href=\"{$comment.comment_author_url}\" title=\"{$comment.comment_author}\">{$comment.comment_author}</a><cond:else />{$comment.comment_author}</cond:if> on {$comment.date} </ul></div>postfix text")) |
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
package minesweeper; | |
import javax.swing.JFrame; | |
import javax.swing.JMenuItem; | |
import javax.swing.UIManager; | |
/** | |
* The Mine Sweeper program. | |
* | |
* @author Peter Goodman |
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
package minesweeper; | |
import java.awt.BorderLayout; | |
import java.awt.Color; | |
import java.awt.Dimension; | |
import java.awt.event.MouseEvent; | |
import java.util.Random; | |
import java.util.Stack; | |
import javax.swing.*; |
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
package minesweeper; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
import java.awt.*; | |
import javax.swing.*; | |
import minesweeper.functional.*; | |
/** |
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
package minesweeper; | |
import java.awt.event.MouseEvent; | |
import javax.swing.*; | |
import javax.swing.event.MouseInputAdapter; | |
import minesweeper.functional.*; | |
import minesweeper.gui.*; | |
import minesweeper.components.*; | |
import static minesweeper.functional.ArrayUtils.map; |
OlderNewer