//<script type="text/javascript">
-
-
+// test code
+
//const Token = imports.Token.Token;
//const Lang = imports.Lang.Lang;
/**
@class Search a {@link JSDOC.TextStream} for language tokens.
*/
-
+
namespace JSDOC {
public class TokenArray: Object {
public new Token get(int i) {
return this.tokens.get(i);
}
+ public void dump()
+ {
+ foreach(var token in this.tokens) {
+ print(token.asString() +"\n");
+ }
+ }
+
}
- errordomain TokenReader_Error {
+ public errordomain TokenReader_Error {
ArgumentError
}
this.line =1;
var tokens = new TokenArray();
- bool eof;
+
while (!stream.lookEOF()) {
-
+
if (this.read_mlcomment(stream, tokens)) continue;
if (this.read_slcomment(stream, tokens)) continue;
if (this.read_dbquote(stream, tokens)) continue;
public bool read_word (TextStream stream, TokenArray tokens)
{
string found = "";
- while (!stream.lookEOF() && Lang.isWordChar((string)stream.look())) {
+ while (!stream.lookEOF() && Lang.isWordChar(stream.look().to_string())) {
found += stream.next();
}
n = this.findPuncToken(tokens, "(", n-1);
//Seed.print('(@' + n);
- var lt = this.lastSym(tokens, n);
+ //var lt = this.lastSym(tokens, n);
/*
//print(JSON.stringify(lt));
if (lt.type != "KEYW" || ["IF", 'WHILE'].indexOf(lt.name) < -1) {
/**
@returns {Boolean} Was the token found?
*/
- public bool read_punc (TextStream stream, TokenArray tokens)
+ public bool read_punc (TextStream stream, TokenArray tokens) throws TokenReader_Error
{
string found = "";
- var name ="";
- while (!stream.lookEOF() && Lang.punc(found + (string)stream.look()).length > 0) {
+
+ while (!stream.lookEOF()) {
+ var ns = stream.look().to_string();
+
+ if (null == Lang.punc(found + ns )) {
+ break;
+ }
found += stream.next();
}
(stream.look() == '<' && stream.look(1) == '!' && stream.look(2) == '-' && stream.look(3) == '-' && (""!=(found=stream.next(4))))
) {
var line = this.line;
- while (!stream.lookEOF() && !Lang.isNewline((string)stream.look())) {
+ while (!stream.lookEOF()) {
+ //print(stream.look().to_string());
+ if ( Lang.isNewline(stream.look().to_string())) {
+ break;
+ }
found += stream.next();
}
- //if (!stream.lookEOF()) { // what? << eat the EOL?
+ if (!stream.lookEOF()) { // lookinng for end of line... if we got it, then do not eat the character..
found += stream.next();
- //}
+ }
if (this.keepComments) {
tokens.push(new Token(found, "COMM", "SINGLE_LINE_COMM", line));
}
while (!stream.lookEOF()) {
if (stream.look() == '\\') {
- if (Lang.isNewline((string)stream.look(1))) {
+ if (Lang.isNewline(stream.look(1).to_string())) {
do {
stream.next();
- } while (!stream.lookEOF() && Lang.isNewline((string)stream.look()));
+ } while (!stream.lookEOF() && Lang.isNewline(stream.look().to_string()));
str += "\\\n";
}
else {
}
continue;
}
- if (stream.look() == "\"") {
+ if (stream.look() == '"') {
str += stream.next();
tokens.push(new Token(str, "STRN", "DOUBLE_QUOTE", this.line));
return true;
*/
public bool read_snquote (TextStream stream, TokenArray tokens)
{
- if (stream.look() != "'") {
+ if (stream.look() != '\'') {
return false;
}
// find terminator
var str = stream.next();
- while (!stream.look().eof) {
- if (stream.look() == "\\") { // escape sequence
+ while (!stream.lookEOF()) {
+ if (stream.look() == '\\') { // escape sequence
str += stream.next(2);
continue;
}
- if (stream.look() == "'") {
+ if (stream.look() == '\'') {
str += stream.next();
tokens.push(new Token(str, "STRN", "SINGLE_QUOTE", this.line));
return true;
*/
public bool read_numb (TextStream stream, TokenArray tokens)
{
- if (stream.look() == "0" && stream.look(1) == "x") {
+ if (stream.look() == '0' && stream.look(1) == 'x') {
return this.read_hex(stream, tokens);
}
var found = "";
- while (!stream.lookEOF() && Lang.isNumber(found+stream.look())){
+ while (!stream.lookEOF() && Lang.isNumber(found+stream.look().to_string())){
found += stream.next();
}
/**
@returns {Boolean} Was the token found?
*/
- public bool read_hex (TokenStream stream, TokenArray tokens)
+ public bool read_hex (TextStream stream, TokenArray tokens)
{
var found = stream.next(2);
while (!stream.lookEOF()) {
- if (Lang.isHexDec(found) && !Lang.isHexDec(found+stream.look())) { // done
+ if (Lang.isHexDec(found) && !Lang.isHexDec(found+stream.look().to_string())) { // done
tokens.push(new Token(found, "NUMB", "HEX_DEC", this.line));
return true;
}
*/
public bool read_regx (TextStream stream, TokenArray tokens)
{
- Token last;
- if (stream.look() != "/") {
+
+ if (stream.look() != '/') {
return false;
}
- var last = tokens.lastSym();
+ var last = tokens.lastSym();
if (
(last == null)
||
var regex = stream.next();
while (!stream.lookEOF()) {
- if (stream.look() == "\\") { // escape sequence
+ if (stream.look() == '\\') { // escape sequence
regex += stream.next(2);
continue;
}
- if (stream.look() == "/") {
+ if (stream.look() == '/') {
regex += stream.next();
- while (GLib.Regex.match_simple("[gmi]", stream.look())) {
+ while (GLib.Regex.match_simple("[gmi]", stream.look().to_string())) {
regex += stream.next();
}