A slightly more complex example of regexp keyed data structures simplifying code.

This app can create simple old-scholl text advetures. It supports getting, dropping and using items along with hidden room discovery.

It's not complete - you will need to add the code for 'win' conditions if you want a conclusion to the game.

The instructions are in the textarea when you run the code.

Code:
<!doctype html>
<html>
<head>
<title>
Simple Text Adenture Parser
</title>
<style type='text/css'>
textarea {display:block;font-size:14pt;}
</style>
</head>
<body>
<!--
The parser relies on regexp keyed data structures,
-->
<div id="info"></div>
<button id="parse">Parse</button> (Create the Game or Clear the Text) &nbsp;&nbsp; 
<span id="runspan"><button id="popit">Pop It</button> (Pop up a window to view your creation) </span>
<textarea id="codeEl" rows="20" cols="100" wrap="off">

Adding a game title
0) the word 'gameTitle' is followed by a space and the games title

Creating rooms: 

The Room Definition Rules:
1) the word 'room' always starts a room definition.
2) the word 'room' is followed by a space and a room name.
   (the following options can be in any order)
3) the word 'look' is followed by a space and a room description.
4) the word 'exits' is followed by a space and a comma-separated list of room names.
5) the word 'content' is followed by a space and a comma-separated list of items found in the room


The Room keywords: room, look, exits, content.
The Item keywords: item, change, additems, addexits, donow, kill, msg, gmsg, score
All keywords: room, look, exits, content, item, change, additems, addexits, donow, kill, msg, gmsg, score

Any line that does not start with a keyword is considered a comment.

Play around - see if you can add more keywords.

--------------------------------------------------
The dashed-line above is not important. It's just another comment.

You can safely remove any or all comments at any time.

The first room definition is always the starting room.
It's the first room described.

***Winehouse Manner***

gameTitle Winehouse Manner

room outside
look You're out side of an expansive old Victorian mansion known as the Winehouse Manner, located just fifteen-minutes north of Dibley, England.
exits entry way, alcove
content note

room alcove
look A small alcove where you can store items you find.
exits outside

room entry way
look You're in a large, vacant entryway just inside the door of Winehouse Manner.
exits kitchen, office, outside
content Persian rug, telephone, umbrella stand

The following is a third room.
Note that you can throw in comments pretty much as you please.

room kitchen
exits entry way, basement
content butcher knife, matches, meat mallet
look You're in a dry, well lit kitchen. the air is thick with the smell of meat, yeast and natural oils.

room office
exits entry way
look You're in a plush office with over-stuffed chairs and a big oak desk.
content map of the house, pen

room basement
look You're in dark dark space. You're too scared to go further.
exits kitchen

room crawl space
look You're in sloping, dark, and tight crawl space.
exits basement, office
content 38 special revolver

Items can change the look description of a room, and/or the contents, and/or the exits.

The Item Definition Rules:
1) the word 'item' always starts an item definition
2) the word 'item' is followed by a space and an item name.
   (the following are optional and can be in any order)
3) the word 'change' is followed by a room name, a comma, and a new room description.
   the indicated room will display the new description when looked at.
4) the word 'additems' is followed by a comma-separated list of items to add to the room.
   the items are placed in the rooms content array.
5) the word addexits is followed by a comma-seperated list of room names.
   the room names are added to the room exits array.
6) the word donow always stands by itself.
   donow forces the action to take place immediately when a content link is clicked.
7) the word 'kill' always stands by itself.
   kill removes the item from inventory and content lists.
8) the word 'msg' is followed by a space and a message.
   msg is local, the player must be in the room to see the message.
9) the word 'gmsg' is followed by a space and a message.
   gmsg is global and will always fire when clicked.
10) the word score is followed by a number that will be added to the score.

*note: addexits and additems can be modified to allow exits and items to be added to any room
       by changing the command structure from: keyword item_list
                                           to: keyword room_name, item_list
	e.g.
        from:  addexits crawl space
          to:  addexits office, crawl space

item matches
change basement, this is a dank, dark, and stinky place to be.
msg You found a lamp in the dark and lit it with the last match in the matchbook.
additems a rope, lever on the wall
score 20
kill

item pen
change outside, You're out side of an expansive old Victorian mansion know as the Winehouse manner located just north of Dibly, England. You've scrawled a message on the mailbox: Jane, I'm in the Mansion.
score 10
kill

item note
gmsg Your playing WineHouse Manner.\nMade with 'Rooms'.

item lever on the wall
change basement, this is a dank, dark, and stinky place to be. There is a small opening in the farthest wall.
msg A loud grinding sound occurs when you pull the lever on the wall
addexits crawl space
score 10
donow
kill

</textarea>
<script>
(function(){
	var btn1 = arguments[0][0];
	var btn2 = arguments[0][1];
	var tbox1 = arguments[0][2];
	var ctain1 = arguments[0][3];
	Array.prototype.foreach=function(fnc){	/* have to account for foreach in all arrays objects this */
		for(var i=0;i<this.length;i++){
			fnc(this[i]);
		}
	}
	var rooms={
		code:"var room=[];\r\n\r\n",
		firstRoom:"",
		room:[],
		curRoom:"",
		init:function(){
			rooms.code="var room=[];\r\n\r\n";
			rooms.firstRoom="";
			rooms.room=[];
			rooms.curRoom="";
		},
		items:{}
	}
	var code=[/* will have RegExp as key and hold associated functions */];
	code["^gameTitle\\s+[\\s\\S]+"]=function(txt){
		var t=txt.replace(/^gameTitle\s+/,"").replace(/\s+/g," ");
		rooms.gameTitle=t;
	};
	code["^room\\s+[\\s\\S]+"]=function(txt){
		var t=txt.replace(/^room\s+/,"");
		if(rooms.firstRoom=="")rooms.firstRoom=t;
		if(typeof rooms.room[t] != "object"){
			rooms.room[t]={
				name:t,
				look:"",
				content:[],
				exits:[]
			};
		}
		rooms.curRoom=t;
	}
	code["^exits\\s+[\\s\\S]+"]=function(txt){
		var t=txt.replace(/^exits\s+/,"").replace(/\s+/g," ");
		var ex=t.split(/,/g);
		rooms.room[rooms.curRoom].exits=ex.join("','").replace(/' /g,"'");
	};
	code["^content\\s+[\\s\\S]+"]=function(txt){
		var t=txt.replace(/^content\s+/,"").replace(/\s+/g," ");
		var ex=t.split(/,/g);
		rooms.room[rooms.curRoom].content=ex.join("','").replace(/' /g,"'");
	};
	code["^look\\s+[\\s\\S]+"]=function(txt){
		var ex=txt.replace(/^look\s+/,"").replace(/\s+/g," ");
		rooms.room[rooms.curRoom].look=ex;
	};
	code["^item\\s+[\\s\\S]+"]=function(txt){
		var ex=txt.replace(/^item\s+/,"").replace(/\s+/g," ");
		rooms.lastItem = ex;
	};
	code["^change\\s+[\\s\\S]+"]=function(txt){
		var t = txt.replace(/^change\s+/,"").replace(/\s+/g," ");
		var rm = t.split(/,/)[0];
		t = t.split(/,/);
		t.slice(0,1);
		var d = t.join(",");
		if(!rooms.items[rooms.lastItem])
			rooms.items[rooms.lastItem]={};
		rooms.items[rooms.lastItem].toroom = rm.replace(/'/g,"\\'");
		rooms.items[rooms.lastItem].newlook = d.replace(/'/g,"\\'");
	};
	code["^additems\\s+[\\s\\S]+"]=function(txt){
		var t = txt.replace(/^additems\s+/,"").replace(/\s+/g," ").replace(/,\s+/g,",").replace(/'/g,"\\'").split(/,/g);
		if(!rooms.items[rooms.lastItem])
			rooms.items[rooms.lastItem]={};
		rooms.items[rooms.lastItem].additems = t;
	};
	code["^addexits\\s+[\\s\\S]+"]=function(txt){
		var t = txt.replace(/^addexits\s+/,"").replace(/\s+/g," ").replace(/,\s+/g,",").replace(/'/g,"\\'").split(/,/g);
		if(!rooms.items[rooms.lastItem])
			rooms.items[rooms.lastItem]={};
		rooms.items[rooms.lastItem].addexits = t;
	};
	code["^kill$"]=function(txt){
		if(!rooms.items[rooms.lastItem])
			rooms.items[rooms.lastItem]={};
		rooms.items[rooms.lastItem].kill = true;
	};
	code["^score\\s+[\\s\\S]+"]=function(txt){
		var t = txt.replace(/^score\s+/,"").replace(/\s+/g,"");
		if(!rooms.items[rooms.lastItem])
			rooms.items[rooms.lastItem]={};
		rooms.items[rooms.lastItem].score = t;
	};
	code["^msg\\s+[\\s\\S]+"]=function(txt){
		var t = txt.replace(/^msg\s+/,"").replace(/\s+/g," ");
		if(!rooms.items[rooms.lastItem])
			rooms.items[rooms.lastItem]={};
		rooms.items[rooms.lastItem].msg = t.replace(/'/g,"\\'");
	};
	code["^gmsg\\s+[\\s\\S]+"]=function(txt){
		var t = txt.replace(/^gmsg\s+/,"").replace(/\s+/g," ");
		if(!rooms.items[rooms.lastItem])
			rooms.items[rooms.lastItem]={};
		rooms.items[rooms.lastItem].gmsg = t.replace(/'/g,"\\'");
	};
	code["^donow$"]=function(txt){
		var t = txt.replace(/^donow\s+/,"").replace(/\s+/g," ");
		if(!rooms.items[rooms.lastItem])
			rooms.items[rooms.lastItem]={};
		rooms.items[rooms.lastItem].donow = true;
	};
	function parse(n){
		for(var i in code){
			var re=new RegExp(i,"i");
			if(re.test(n)){
				code[i](n);
			}
		};
	}
	/* the bulk of the game is one string */
	var game="<"+"!doctype html"+">\r\n<" +"html"+ ">\r\n \
<title>[TITLE]</title>\r\n \
<style>\r\n \
body {margin:0px; font-size:11pt; font-family:Chalkboard, Comic Sans MS, Comic Sans, TSCu_Comic; background:black;}\r\n \
.look {position:relative;height:80px; font-size:16pt;font-family:Tempus Sans ITC, Tempus Sans, Purisa, Verdana; background:black; color:white;padding:10px;}\r\n \
.see {font-size:18pt;font-family:Tempus Sans ITC, Tempus Sans, Purisa, Verdana; background:black; color:yellow;padding:10px;}\r\n \
.go {font-family:Tempus Sans ITC, Tempus Sans, Purisa, Verdana; background:navy; color:#66ccff;padding:10px;}\r\n \
a {color: white}\r\n \
.inv {font-family:Tempus Sans ITC, Tempus Sans, Purisa, Verdana; background:white; color:navy;padding:10px;border:solid 2px black;}\r\n \
.inv a {color:red;font-weight:bold;}\r\n \
.score {font-size:18pt;font-family:Tempus Sans ITC, Tempus Sans, Purisa, Verdana; background:black; color:yellow;padding:10px;text-align:right;}\r\n \
h1 {padding-left:10px;background:#fff;color:#000;}\r\n \
</style>\r\n \
<body>\r\n \
<h1>[TITLE]</h1>\r\n \
<div id=\"game\"></div>\r\n \
<scr" +"ipt>\r\n \
var $=function(n){return document.getElementById(n)}\r\n \
[game] \
room.items={};\r\n \
room.curRoom;\r\n \
room.score=0;\r\n \
var inventory=[];\r\n \
function grab(ob,item){\r\n \
 	inventory[item]=1;\r\n \
	var oc=ob.content;\r\n \
	for(var i=0;i<oc.length;i++){\r\n \
		if(oc[i]==item){\r\n \
			oc.splice(i,1);\r\n \
			break;\r\n \
		}\r\n \
	}\r\n \
	if(room.items[item] && room.items[item].donow){\r\n \
		room['items'][item]();\r\n \
		delete inventory[item];\r\n \
	}\r\n \
	play(ob);\r\n \
}\r\n \
function play(ob,n){\r\n \
	room.curRoom = ob;\r\n \
	if(n){\r\n \
		if(room['items'][n]){\r\n \
			room['items'][n]();\r\n \
		}else{\r\n \
			ob.content.push(n);\r\n \
			delete inventory[n];\r\n \
		}\r\n \
	}\r\n \
 	var s=\"<div class='score' id='score'>SCORE: \"+room.score+\"</div>\"\r\n \
	s+=\"<div class='look'>\"+ob.look+\"</div>\"\r\n \
	s+=\"<div class='see'>You can see: \"\r\n \
	for(var i=0;i<ob.content.length;i++){\r\n \
		if(!(ob.content[i]==null || ob.content[i].replace(/\s/g,\"\")==\"\"))\r\n \
			s += \"<a href='#' onclick='grab(room[\\\"\"+ob.name+\"\\\"],\\\"\"+ob.content[i]+\"\\\");return false;'>[\"+ob.content[i]+\"]</a> \";\r\n \
	}\r\n \
	s+=\"</div>\"\r\n \
	s+=\"<div class='go'>From here you can go: \"\r\n \
	for(var i=0;i<ob.exits.length;i++){\r\n \
		s += \"<a href='#' onclick='play(room[\\\"\"+ob.exits[i]+\"\\\"]);return false;'>[\"+ob.exits[i]+\"]</a> \";\r\n \
	}\r\n \
	s+=\"</div>\"\r\n \
	s+=\"<div class='inv'>Your Things: \"\r\n \
 	for(var i in inventory){\r\n \
		if(i!=\"foreach\")\r\n \
		s += \"<a href='#' onclick='play(room[\\\"\"+ob.name+\"\\\"],\\\"\"+i+\"\\\");return false;'>[\"+i+\"]</a> \";\r\n \
	}\r\n \
	s+=\"</div>\"\r\n \
	$('game').innerHTML=s;\r\n \
}\r\n \
[INV]\r\n \
play(room['[firstRoom]'])\r\n \
</scr" +"ipt>\r\n \
</body" +">\r\n</html>";
	/* end of the game string */

	var $=function(n){return document.getElementById(n)}
	function setup(){
		$(btn1).flag=true;
		$(btn1).onclick=function(){
			if($(btn1).flag){
				var a = $(tbox1).value.replace(/\r/g,"").split(/\n/g);
				a.foreach(parse);
				for(var i in rooms.room){
					if(i!="foreach"){
						rooms.code+="room['"+i+"']={};\r\n \
	room['"+i+"'].name=\""+rooms.room[i].name+"\";\r\n \
	room['"+i+"'].look=\""+rooms.room[i].look+"\";\r\n \
	room['"+i+"'].content=['"+rooms.room[i].content+"'];\r\n \
	room['"+i+"'].exits=['"+rooms.room[i].exits+"'];\r\n\r\n";
					}
				}
				game = game.replace(/\[game\]/,rooms.code).replace(/\[firstRoom\]/,rooms.firstRoom);
	
				var s="";
				for(var i in rooms.items){
					s+= "\r\n room.items['"+i+"']=function(){\r\n";
					if(rooms.items[i].toroom){
						s+="\tif(room.curRoom.name=='"+rooms.items[i].toroom+"'){\r\n";
						if(rooms.items[i].newlook)
							s+="\t\troom['"+rooms.items[i].toroom+"'].look='"+rooms.items[i].newlook+"';\r\n";
						if(rooms.items[i].additems){
							for(var j=0;j<rooms.items[i].additems.length;j++)
								s+="\t\troom['"+rooms.items[i].toroom+"'].content.push('"+rooms.items[i].additems[j]+"');\r\n";
						}
						if(rooms.items[i].addexits){
							for(var j=0;j<rooms.items[i].addexits.length;j++)
								s+="\t\troom['"+rooms.items[i].toroom+"'].exits.push('"+rooms.items[i].addexits[j]+"');\r\n";
						}
						if(rooms.items[i].kill){
							s+="\t\tdelete inventory['"+i+"'];\r\n"+
							"\t\tdelete room['items']['"+i+"'];\r\n";
						}
						if(rooms.items[i].score)
							s+="\t\troom.score+="+rooms.items[i].score+";\r\n";
						if(rooms.items[i].msg)
							s+="\t\talert('"+rooms.items[i].msg+"');\r\n";
						s+="\t}\r\n";
					}
					if(rooms.items[i].gmsg)
						s+="\talert('"+rooms.items[i].gmsg+"');\r\n";
					s+=" }\r\n";
					if(rooms.items[i].donow){
						s+=" room.items['"+i+"'].donow=true;\r\n";
					}
				}
	
				game = game.replace(/\[INV\]/,s).replace(/\[TITLE\]/g,function(){return rooms.gameTitle||"A ROOMS GAME"});
	
				$(tbox1).value=game;
				$(btn1).innerHTML="Clear";
			}else{
				rooms.init();
				$(tbox1).value="";
				$(btn1).innerHTML="Parse";
			}
			$(btn1).flag=!$(btn1).flag;
			$(ctain1).style.display="inline";
		}
	}

	$(ctain1).style.display="none";
	$(btn2).onclick=function(){
		var w=window.open('about:blank');
		w.document.open();
		w.document.write($(tbox1).value);
		w.document.close();
	}
	setup();
})([
	"parse",  /*required: id for parse button*/
	"popit",  /*required: id for popup window button*/
	"codeEl", /*required: id for code textbox*/
	"runspan" /*required:id for popup window buttons immediate container*/
]);
</script>
</body>
</html>

tested in ie,ff,chrome,safari,opera