April 20th, 2009
Format for a simple grammar description language.
Syntax = Identifier {CRLF Rule}
Rule = {Identifier “=” Description}
Identifier = [Letter | Digit]
Description = {Node {” ” Node} }
Node = ZeroToMany|OneToMany|Symbol|TextString
TextString = “\”" [Letter|Digit] “\”"
ZeroToMany = “{” Node “}”
OneToMany = “[" Node "]”
Grouping = “(” Node “)”
UnknownContent = “…”
CRLF = <system dependent>
Example:
Javascript
Array_Literal = “[" {Expression {Expression ","} } "]”
Block = “{” {Statements} “}”
Break_Statement = “break” {Label_Name} “;”
Case_Clause = ["case" Expression ";"] Statements
Disruptive_Statement = [Break_Statement | Return_Statement | Throw_Statement]
Do_Statement = “do” Block “while” “(” Expression “)” “;”
Escaped_Character = “\” (”\” | “\’” | “\\” | “\/” | “b” | “f” | “n” | “r” | “t” | UnicodeChar)
UnicodeChar = “u” HexDigit HexDigit HexDigit HexDigit
Exponent = ["e" | "E"] {”+” | “-”} [Digit]
Expression = [Literal | Name | "(" Expression ")" | Prefix_Operator Expression | New_Expression | Delete_Expression | Complex_Expression]
Complex_Expression = Expression ( Infix_Operator Expression | “?” Expression “:” Expression | Invokation | Refinement )
New_Expression = “new” Expression Invokation
Delete_Expression = “delete” Expression Refinement
Expression = Name ({Refinement} Assignment_Operator | Additive_Operator | Subtractive_Operator ) | …
For_Statement = “for” “(” ( ( Name “in” Object ) | ( Initializtion_Statement “;” Condition_Statement “;” Increment_Statement ) ) Block
Fraction = “.” Digit
Function_Body = “{” Var_Statements Statements “}”
Function_Literal = “function” ( Name | “” ) Function_Params Function_Body
If_Statement = “if” “(” Expression “)” Then_Block {”else” ( If_Statement | Block )}
Infix_Operator = Multiply | Divide | Modulo | Add | Subtract | GreaterOrEqual | LessOrEqual | Greater | Less | EqualTo | NotEqualTo | LogicalOr | LogicalAnd
Multiply = “*”
NonZeroDigit = “1″ | “2″ | “3″ | “4″ | “5″ | “6″ | “7″ | “8″ | “9″
Digit = “0″ | NonZeroDigit
Integer = “0″ | ( NonZeroDigit {Digit} )
Invocation = “(” Expression { “,” Expression } “)”
Literal = Number_Literal | String_Literal | Object_Literal | Array_Literal | Function_Literal | RegExp_Literal
Name = [ Letter | Digit | "_" ]
Number_Literal = Integer {Fraction} {Exponent}
Object_Literal = “{” { Field_Assignment {Field_Assignment “,” } } “}”
Function_Parameters = “(” Name { “,” Name } “)”
Prefix_Operator = “typeof”| “+” | “-” | “!”
Refinement = “.” Name | “[" Expression "]”
Return_Stmt = “return” ( Expression | “” ) “;”
Statements = { {StatementLabel “:”} Expression_Statement “;” | Disruptive_Stmt | Try_Stmt | If_Stmt | Switch_Stmt | While_Stmt | For_Stmt | Do_Stmt }
String_Literal = …
Switch_Statement = “switch” “(” Expression “)” “{” Switch_Body “}”
Switch_Body = Case_Clause { Disruptive_Stmt (Switch_Body | Switch_Default) } “}”
Switch_Default = “default” “:” Statements
Throw_Stmt = “throw” Expression “;”
Try_Stmt = “try” Block “catch” “(” Variable_Name “)” Block
Var_Assignment = “Name” “=” Expression
Var_Stmt = “var” (Name | Var_Assignment) {”,” Var_Assignment} “;”
While_Stmt = “while” “(” Expression “)” Block
Whitespace = ” ” | “\t” | CRLF | Comments
Comments = ( “\\” NonLineEndChars CRLF ) | ( “\*” … “*/”)
Technorati : Javascript
Del.icio.us : Javascript
Zooomr : Javascript
Flickr : Javascript
Tags: Javascript
Posted in Uncategorized | No Comments »
April 15th, 2009
Simple Schema
I. Synopsis
Simple Schema is a proposal for a definition/description language, to allow the easier description and development of object oriented software systems and individual data type definitions. Core design goals are:
Platform and language independence. Descriptions rely only on text, as opposed to description methods that are tied to other formats like XML. Also, is not bound to any programming language or software platform.
Simplicity. Using Simple Schema should be easy to learn, and easy to create parsers for (for translation to code generation tools, diagramming tools, etc..).
It is intended that software designers can express conceptual software models using only a text editor, and that tools will exist to transform these models to diagramming tools, code generators, etc.., and enable more intelligent integrated software systems that can easily transmit and receive software component and data type definitions.
II. Description of the language
BNF
SchemaCollection = Schema+ .
Schema = Item (system_line_break (”<tab>” Element system_line_break)+)* .
Item = (”+”|”-”)* (”(” (’class’|”interface”|data_type) “)”)+ ItemName (”<” Class_Inherited|Interface_Implmented “<”)* .
Element = (Item | FunctionDef)*
FunctionDef = (”+”|”-”)* (”(” Return_Type “)”)* FunctionName “(” (FunctionParams)* “)” .
Syntax Diagram

Posted in Uncategorized | No Comments »
March 2nd, 2009
$h = mysql_connect($_host,$_user,$_pwd);
mysql_select_db($_db);
$res = mysql_db_query($_db, $strQuery);
while($r = mysql_fetch_array($res)) {
foreach ($r as $k => $v) {
echo “$k;$v”;
}
echo “\n”;
}
mysql_close($handle);
Technorati : MySQL, PHP
Del.icio.us : MySQL, PHP
Zooomr : MySQL, PHP
Flickr : MySQL, PHP
Tags: MySQL, PHP
Posted in PHP | No Comments »
March 2nd, 2009
<?
$c = odbc_connect(”dsnname”, “username”, “pass”);
$res = odbc_exec($connect, “SELECT firstname,lastname FROM users”);
while($r = odbc_fetch_array($res)) {
foreach ($r as $k => $v) {
echo “$k;$v”;
}
echo “\n”;
}
odbc_close($c);
?>
Technorati : ODBC, PHP
Del.icio.us : ODBC, PHP
Zooomr : ODBC, PHP
Flickr : ODBC, PHP
Tags: ODBC, PHP
Posted in Uncategorized | No Comments »
February 27th, 2009
function socket_raw_connect ($server, $port, $timeout,$request) {
if (!is_numeric($port) or !is_numeric($timeout)) {return false;}
$socket = fsockopen($server, $port, $errno, $errstr, $timeout);
fputs($socket, $request);
$ret = ”;
while (!feof($socket))
{
$ret .= fgets($socket, 4096);
}
return $ret;
fclose($socket);
}
Technorati : PHP, socket
Del.icio.us : PHP, socket
Zooomr : PHP, socket
Flickr : PHP, socket
Tags: PHP, socket
Posted in PHP | No Comments »
February 19th, 2009
function delf($fn) { if($fn != “” && file_exists($fn)) unlink($fn); }
Technorati : file, php
Del.icio.us : file, php
Zooomr : file, php
Flickr : file, php
Tags: file, PHP
Posted in PHP | No Comments »
February 19th, 2009
function htget($URL) { return file_get_contents($URL) }
Technorati : http, php
Del.icio.us : http, php
Zooomr : http, php
Flickr : http, php
Tags: http, PHP
Posted in PHP | No Comments »
February 19th, 2009
/* Show errors in script */
ini_set(’display_errors’,1);
error_reporting(E_ALL|E_STRICT);
Technorati : errors, php
Del.icio.us : errors, php
Zooomr : errors, php
Flickr : errors, php
Tags: errors, PHP
Posted in PHP | No Comments »
February 17th, 2009
Quick and dirty ajax
function quickaj(u) {
if(window.ActiveXObject) {
var x = new ActiveXObject(”Microsoft.XMLHTTP”);
} else {
var x = new XMLHttpRequest();
}
x.open(”GET”,u, false);
x.send(null);
return x.responseText;
}
Technorati : ajax, javascript
Del.icio.us : ajax, javascript
Zooomr : ajax, javascript
Flickr : ajax, javascript
Tags: ajax, Javascript
Posted in Uncategorized | No Comments »
February 10th, 2009
function mailf($toaddr,$fromaddr,$mfromname,$msub,$msg) {
mail($toaddr, $msub, $msg, “From: $fromaddr <$mfromname>\r\n”)
}
Technorati : PHP, mail
Del.icio.us : PHP, mail
Zooomr : PHP, mail
Flickr : PHP, mail
Tags: mail, PHP
Posted in PHP | No Comments »