Jane Parsing Logic



Jane divides search into two types:

TYPE I --  A search in a large body of text for specific values
TYPE II -- A parse for a specific format, such as a date, address, file, url, or email formatted strings

Using a combination of both types can be used to speed up complex logical searches. An example would be to use a Type I search for a "/" string then using a Type II parse to determine if the preceding and following text is a url or a file name formatted string.
 
 


TYPE I

A "Search" based on some very specific known value.  Search can be on Strings, Objects and Arrays.

The "search" is a statement in the Jane Language.  It provides the location of a string within the content of a given JavaScript value. The statement permits wildcard matches, and complex conditionals to locate a string.  The search can continue on the "preceding" string and./or on the "following" string.  The "preceding" "found" and "preceding" strings values can be recursively searched to any depth.

B = search A for "Apple" preceded by a proper name or followed by a proper name;
The "search" statement is a execute on reference. The "B" value above is the search statement, it can then be used in a the "loop", "for", "locate",  and "replace" statement.  
for (value in B) {...}
loop B (index,value) {...}

while (true)
{
	c = B;
	if (c == null) break;
	alert(c);
}

C = replace B with "Bradford Pear";

D = locate first B;


TYPE II

A "Parse" of a specific format, starting at a given position. The use of "parse" is to validate, extract, and/or reformat known complex text formats. You may use your own formatting definitions as illustrated in the first tab on this page. The definition of a "parse" is a JavaScript object containing:

The syntax:  set of words,  AND each word, followed by 0 or more commas OR (white space separated)

this.Language = "The little brown fox, The big bad wolf"

"the" AND "little" AND "brown" AND "fox"
                OR
"the" AND "big" AND "bad" AND "wolf"

Parsing Syntax:

(name)
(systemlist)




{syntax}
[syntax]
<opcode>

#:min-max
$
@
!syntax
~
syntax...
quoted string
search ".syntax.name" calling method ".action.name" if found
system defined lists: color, state, country, city, county, university, president, time, era, date,
verb, noun, adjective, adverb, preposition, conjunction, phrase, location, direction, slang, distance,
solid, gas, liquid, units, element, temperature, angle, house, tool, hospital, religion, songs, relation,
boy, girl (qualifiers [.name, nickname, title, epithet])
person (qualifiers [.historical, .political, .actor, .singer, .musician, .comedian, .writer])
syntax is optional, true condition if found or not
syntax can be an Array (comma, semi-colon or "and" separated)
opcodes: <eod> end-of-data <eoln> end-of-line <comma> a comma
<(...)> <[...]> <{...}> <<...>> anything between () [] {} <>
a number, with an optional :range, searching for standard Integer, Float, Hex, Octal, Binary and word numbers
a proper name
any word
not syntax
all remaining text
repeat while true (append into a single value)
match any of the characters in the string (forever)
this.Animal 	= new Object();
this.action 	= new Object();
this.syntax 	= new Object();

this.Language		= "{the} {(size)} {(color)...} (animal)";
this.syntax.animal	= "fox,wolf,bear";
this.syntax.size	= "big,little,small,really big,baby,mama,papa,mother,father";
this.syntax.color	= "brown,red,blue,green,yellow,black";

this.action.size = function (index,language,text,value) { this.Animal.size = text; } this.action.color = function (index,language,text,value) { this.Animal.color += ' ' + text; } this.action.animal = function (index,language,text,value) { this.Animal.type = text; }
matches:
The really big red green fox
wolf
the big bear
red fox

REPLACE

The "replace" is a statement in the Jane Language, that uses a Search object to change matched values

C = replace A with "Clingstone Peaches" prompt


SPLIT

The "split" is a statement in the Jane Language, that uses system define logic to separate into an Array object by commonly known structures and by a "search" object. The objective is to handle common formats, JavaScript, CSV, HTML, ...

A = split myJavaScript as JavaScript by function;

Locate (sub search)

Using a "search" object to create another "search" object of specific elements

B = search A for HTML_Tags
C = locate in B where tagname = 'script';

or

C = locate in (search A for HTML_Tags) where tagname = 'script'

Compiler

Compiler is to create a custom compiler using the JavaScript syntax, Jane extensions, and/or user defined statement syntax.


	upper = /* ... */; 	// see: "compiler" tab for "upper" statement syntax 

	myStatements = [upper];
	myStatements.include = JavaScript_statement_names + Jane_statement_names;

	A = new Compiler(myStatements);

	script = 'A = "clif Collins"; B = upper A + ' Hello World' ; alert(A);';
	
	alert(A.sourcecode);
	A.saveAs('win32','bob.exe');	
	A.saveAs('javascript','bob.js');
	program = A.compile(script);
	program.run();
	
	or
	
	eval(A.sourcecode);
	bob = new JavaScript$();
	program = bob.compile(script);
	program.run();