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
/** | |
* This is a skeleton code to implement a iterable lexer. Which is able to be processed in a convenient | |
* for-each loop... | |
*/ | |
public class ActionLexer implements Iterable<ActionToken> { | |
private Reader reader; | |
// 19 status total | |
private static final int[] stats = new int[19]; |
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
/** | |
* | |
* This is the code skeleton for arbitrary-lookahead LL parser. Look ahead tokens are cached. | |
* | |
*/ | |
public class ActionParser { | |
private ActionLexer lexer; | |
// buffered tokens that were look-ahead | |
private List<ActionToken> aheadBuffer = new ArrayList<ActionToken>(); |
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
// hidden inputs created have the same name as the disabled select, so the select must have its 'name' attr | |
function readOnlySelect(sel) { | |
if (typeof $(sel).next('input[type=hidden]').attr('name') == 'undefined' | |
|| $(sel).next('input[type=hidden]').attr('name') != $(sel).attr( | |
'name')) { | |
$(sel).after([ '<input type="hidden" name="', $(sel).attr('name'), | |
'" value="', $(sel).val(), '" />' ].join('')); | |
} | |
$(sel).attr('disabled', true); |
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
public class ComparingNode implements DataFilterNode { | |
public <P, R> R accept(DataFilterVisitor<P, R> visitor, P param) { | |
return visitor.visitComparingNode(this, param); | |
} | |
} |
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 re | |
class TokenType(object): | |
QUANTIFIER, ESCAPE_CHAR, UNICODE_CHAR, LEFT_PAREN, RIGHT_PAREN, OR, ALPHA, DIGIT, DOT, LEFT_BRACKET, NOT_IN, RIGHT_BRACKET, DASH, DERIVES, UNDER_SCORE, EOF, WHITE_SPACE = range(17) | |
def lexer(code): | |
""" | |
The lexical analysis function for itself's lexical rules. This lexer is 'iterable', | |
thus you can traverse all the tokens in the for..in statement til the EOF token reached. | |
""" |
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
def aStarSearch(problem, heuristic=nullHeuristic): | |
from sets import Set | |
visited = Set() | |
start = problem.getStartState() | |
from util import PriorityQueue | |
frontLine = PriorityQueue() | |
startPri = 0 + heuristic(start, problem) | |
frontLine.push((start, [], 0), startPri) | |
while not frontLine.isEmpty(): | |
(point, actions, cost) = frontLine.pop() |
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
# the 'map' | |
colors = [['red', 'green', 'green', 'red' , 'red'], | |
['red', 'red', 'green', 'red', 'red'], | |
['red', 'red', 'green', 'green', 'red'], | |
['red', 'red', 'red', 'red', 'red']] | |
# the results of sensor | |
measurements = ['green', 'green', 'green' ,'green', 'green'] | |
# motions |
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
# Tag Cloud for Octopress, modified by pf_miles, for use with utf-8 encoded blogs(all regexp added 'u' option). | |
# ======================= | |
# | |
# Description: | |
# ------------ | |
# Easy output tag cloud and category list. | |
# | |
# Syntax: | |
# ------- | |
# {% tag_cloud [counter:true] %} |
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 test; | |
import com.github.pfmiles.dropincc.Action; | |
import com.github.pfmiles.dropincc.CC; | |
import com.github.pfmiles.dropincc.Exe; | |
import com.github.pfmiles.dropincc.Grule; | |
import com.github.pfmiles.dropincc.Lang; | |
import com.github.pfmiles.dropincc.TokenDef; | |
public class Test { |
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 com.github.pfmiles.dropincc.Action; | |
import com.github.pfmiles.dropincc.CC; | |
import com.github.pfmiles.dropincc.Exe; | |
import com.github.pfmiles.dropincc.Grule; | |
import com.github.pfmiles.dropincc.Lang; | |
import com.github.pfmiles.dropincc.TokenDef; | |
public class Calculator { | |
private static Exe exe = null; | |
/** |