All pastes #824976 Raw Edit

James

public text v1 · immutable
#824976 ·published 2007-12-20 07:34 UTC
rendered paste body
function gettok() {
  if (tok == "(eof)") return "(eof)"
  sub(/^[ \t]+/, "", line)
  tokno++;
  while ((nlen=length(line)) == 0) {
    	if(getline line == 0)
    		return tok = "(eof)"
    	if (line ~ /^[0-9][0-9][0-9][0-9]/) {
      		lineno = substr(line, 1, 4);
      		line = substr(line, 5);
      	} else line =""
      sub(/^[ \t]+/, "", line)
      	tokno = 0
    }
    if (line ~ /^[A-Za-z]/) {
      	nxtn = 1
      	xline = substr(line, 2);
      	while((xline ~ /^[A-Za-z_0-9]/) && (nxtn < nlen)) {
        		nxtn++;
        		xline = substr(xline, 2);
        	}
      }
      else if (line ~ /^./) {
        	nxtn =1 
      }
      tok = substr(line, 1, nxtn)
      line = substr(line, nxtn+1)
      return tok
    }
  }
}