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
%{ | |
int nchar, nword, nline; | |
%} | |
%% | |
\n { nline++; nchar++; } | |
[^ \t\n]+ { nword++, nchar += yyleng; } | |
. { nchar++; } | |
%% |
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
grammar Expr; | |
@header { | |
package test; | |
import java.util.HashMap; | |
} | |
@lexer::header {package test;} | |
@members { |
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
grammar ExprAst; | |
options { | |
output=AST; | |
ASTLabelType=CommonTree; // type of $stat.tree ref etc... | |
} | |
prog: ( stat {System.out.println($stat.tree.toStringTree());} )+ ; | |
stat: expr NEWLINE -> expr | |
| ID '=' expr NEWLINE -> ^('=' ID expr) |
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 AddCharDemo | |
{ | |
public static void main(String []args) { | |
int i = 3; | |
int j = 5; | |
System.out.println(i + ' ' + j); | |
System.out.println(' ' + 0); | |
} | |
} |
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 IncDemo | |
{ | |
public static void main(String []args) { | |
int i = 2; | |
i = i++; | |
System.out.println("int i = 2; i = i++ equals: " + i); | |
} | |
} |
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
-- hex dump | |
-- usage: lua xd.lua < file | |
local offset=0 | |
while true do | |
local s=io.read(16) | |
if s==nil then return end | |
io.write(string.format("%08X ",offset)) | |
string.gsub(s,"(.)", | |
function (c) io.write(string.format("%02X ",string.byte(c))) end) |
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
use strict; | |
use warnings; | |
use Purple; | |
our %PLUGIN_INFO = ( | |
perl_api_version => 2, | |
name => "Fortune Plugin", | |
version => "0.1", | |
summary => "Fortune plugin.", | |
description => "Set fortune output as status when plugin load.", |
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
#! /usr/bin/guile -s | |
!# | |
(let* ((yin ((lambda (foo) (newline) foo) | |
(call-with-current-continuation (lambda (bar) bar)))) | |
(yang ((lambda (foo) (write-char #\*) foo) | |
(call-with-current-continuation (lambda (bar) bar))))) | |
(yin yang)) |
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 twisted.words.xish import domish | |
from wokkel.xmppim import MessageProtocol, AvailablePresence | |
class EchoBotProtocol(MessageProtocol): | |
def __init__(self, component=False): | |
MessageProtocol.__init__(self) | |
self.component = component |
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
-module(countdown). | |
-export([countdown/1]). | |
countdown(0) -> io:format("Blast Off!~n"); | |
countdown(X) -> io:format("~w~n", [X]), countdown(X-1). |