Thread: Some parsers
View Single Post
  #1  
Old 01-01-2008, 04:16 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Some parsers

Well, lately when I didn't have subscription I felt like.. making parsers for some really odd reason, don't ask why

Anyways,
PHP Code:
/*      Made by Chompy
         Parser v1.0

    Usage:
    
      <$var|this.var$>
      
      <$function|function(params)$>
         * params can't be spaced (ex. (foo, bar)), have to be (foo,bar)
*/
public function cParse(a) {
  
temp.temp.a.tokenize(" ");
  
  
temp.0;
  for(
temp.b) {
    if (
c.pos("<$") > -1) {
      
temp.c.substring(0c.pos("<$") + 2);
      
temp.c.substring(d.length(), c.pos("|") - d.length());
      
temp.c.substring(c.pos("|") + 1c.pos("$>") - (d.length() + e.length()) - 1);
      
temp.c.substring(c.pos("$>") + 2);
      switch(
e) {
        case 
"var":
          
b[i] = d.substring(0d.length() - 2);
          
b[i] @= makevar(f);
          
b[i] @= g;
        break;
        case 
"function":
          
temp.f.substring(0f.pos("("));
          
temp.f.substring(f.pos("(") + 1f.pos(")") - (j.length() + 1));
          if (
makevar(k) != NULL) {
            
makevar(k);
          }
          
temp.k.tokenize(",");
          
temp.= (@ j)(@ p[0], p[1], p[2], p[3], p[4], p[5], p[6]);
          
b[i] = d.substring(0d.length() - 2);
          
b[i] @= l;
          
b[i] @= g;
        break;
        default:
          if (
0) {
            
b[i-1] = b[i-1].substring(0b[i-1].length());
          }
          
b[i] = d.substring(0d.length() - 2);
          
b[i] @= g;
        break;
      }
    }
    
++;
  }
  
temp."";
  for(
temp.str b) {
    
@= str " ";
  }
  return 
h;

Basicly, you can do:

PHP Code:
function onCreated() {
  
this.nick "Chompi";
  echo(
cParse("Hi <$var|this.nick$>!"));

And it will output "Hi Chompi!".

It will parse all variables and functions it finds


I'll also use this thread to post my other parsers that I've made, so.. have fun? xD
(PS: I know they probably isn't for good use, butI learnt much out of making parsers so by reading them or making your own, you learn how things works :o)
__________________
Reply With Quote