[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sigh... really, i'm not dead.



> <P>Implementations should never send a message with duplicate argument
> keywords; for example, the message
...
This text looks good, but maybe it should explicitly handle the 
following case:

#$#say 123345 what: "Hats off" what*: "" _data-tag abc
#$#* 123345 what: Hats on
#$#END 123345

> about the #$#text-line suggestion (john ramsdell suggested a
> #$#text-line message which is completely equivalent to its text:
> argument alone): i dunno.  this seems redundant to me.  the argument
> was: 
> 
> > With this addition, one could implement an MCP parser that always
> > returns an MCP object, and the MCP object for a text line would have
> > text-line as its request and a text argument. 
> 
> couldn't you do this without the message?  just have your parser
> fall-through on messages not beginning with '#$#' to create a
> 'non-mcp text line' MCP object?

So your idea is to have

abstract class MUDObject { ... }

class MUDText extends MUDObject { String getLine() { ... } ... }

class MCPObject extends MUDObject { String getRequest() { ... } ... }

class MUDParser { 
  MUDParser(BufferedReader in) { ... } 
  MUDObject parse() { ... }
  ...
}

and then a use of the parser would follow this pattern:

MUDParser mud = ...;
...
for (;;) {
  MUDObject mo = mud.parse();
  if (mo == null) {  handle end of input }
  else if (mo instanceOf MUDText) { handle text line }
  else if (mo instanceOf MCPObject) {
    MCPObject mcp = (MCPObject)mo;
    String req = mcp.getRequest();
    dispatch on the request.
  } else error
}

My idea is to reserve a request name for text lines so that all
dispatching can be done by simply looking at the request.  In this
model, the above loop looks like:

MUDParser mud = ...;
...
for (;;) {
  MCPObject mcp = mud.parse();
  if (mcp == null) {  handle end of input }
  else {
    String req = mcp.getRequest();
    dispatch on the request.
  }
}

with 

class MUDParser { 
  MUDParser(BufferedReader in) { ... } 
  MCPObject parse() { ... }
  ...
}

John