473,796 Members | 2,601 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need ideas on how to approach this.

I want to make a program that reads the content of a LUA array save file..
More precicely a save file from a World of Warcraft plugin called
CharacterProfil er, which dumps alot of information about your characters
into that save file.

Anyhow, I want to extract a couple of lines of it and save it into a
database and I need help on figuring out a good way of reading the file.
The problem is that the file can look pretty different depending on the
proffessions and class of the characters etc. etc..

Is it possible to get an xml parser to read it or something?

I would appriciate all angles of approaching this..
Right now im thinking about just starting with getting rid of the stuff I
dont want in the file.. Like I only want the characters from a certain
server.. Trollbane. And I only want information about characters in the
guild Sacred Order Of Azeroth...
So if I just catch the part in the file where it starts with ["Trollbane"] =
{ and counts the '{' and '}' to get the one that ends the trollbane server..

Anyway, Im attaching the whole save file so that you can take a look at it..
Hope someone can give me some ideas.

EDIT: Aww, it was to big to send with..Im uploading it to a webspace
http://www1.shellkonto.se/artix/CharacterProfiler.lua

Mar 21 '07 #1
2 1811
Anders B wrote:
I want to make a program that reads the content of a LUA array save file..
More precicely a save file from a World of Warcraft plugin called
CharacterProfil er, which dumps alot of information about your characters
into that save file.

Anyhow, I want to extract a couple of lines of it and save it into a
database and I need help on figuring out a good way of reading the file.
The problem is that the file can look pretty different depending on the
proffessions and class of the characters etc. etc..

Is it possible to get an xml parser to read it or something?

I would appriciate all angles of approaching this..
Right now im thinking about just starting with getting rid of the stuff I
dont want in the file.. Like I only want the characters from a certain
server.. Trollbane. And I only want information about characters in the
guild Sacred Order Of Azeroth...
So if I just catch the part in the file where it starts with
["Trollbane"] =
{ and counts the '{' and '}' to get the one that ends the trollbane
server..

Anyway, Im attaching the whole save file so that you can take a look at
it..
Hope someone can give me some ideas.

EDIT: Aww, it was to big to send with..Im uploading it to a webspace
http://www1.shellkonto.se/artix/CharacterProfiler.lua
Just a hint: to get a grip on the file structure I'd use an editor
supporting lua with folding capabilities like notepad++
With alt-0..8 alt-shift-0..8 you can (un)fold levels 0 for all up to
level 8 and see line numbers.

http://notepad-plus.sourceforge.net/

--
Greetings
Matthias
Mar 21 '07 #2
Anders B wrote:
<backposted />

I don't know Lua nor the specific format it uses, but based on the
file you posted, I suppose you could come up with a LUA -XML
translator quite easily, with a minimum of hair pulling (there will be
some, though), and a maximum of fun for, say, a rainny afternoom.

To write such parser, you could start with a "grammar" for the file
format, which would be something like the follwoing (again, roughly
based on the file you posted):

Items = Item+ EOF
Item = Name '=' ContentBlock
ContentBlock = '{' Content* '}'
Content = (AttributeOrIte m
| UnamedItem
| Nil
| SubItem) ','

AttributeOrItem = Name '=' (Literal | ContentBlock)
UnamedItem = ContentBlock
Nil = NIL
SubItem = Literal

Name = Identifier
| ('[' Literal ']')

Where Identifier, Literal, NIL and EOF are tokens (as well as the
symbols "{", "}", "[", "]", "," and "="). In the pseudo-grammar above,
the '+' symbol means that the preceding item may exist one or more
times; the '*' means that the preceding item is on optional sequence;
and the '|' symbol indicates alternatives.

While parsing this grammar, you could map each construct to a XML-like
element:

Item -<item name="name">... </item>
Attribute -<attribute name="name" value="value" />
Nil -<item name="" />
UnamedItem -<item name=""... </item>
SubItem -<subitem value="value" />

To build a parser from this grammar, you'd first need a Lexer which
would return each different token on demand. This is somewhat tricky,
and would be a whole lot of fun in itself (you see that my concept of
fun leaves a lot to be desired)...

Then, for each non-terminal in the grammar above (a non-terminal is
one of the names to the left of the equal sign: Items, Item,
ContentBlock, etc) you would create a parsing method responsible for
"recognizin g" the pattern to the right of the equal sign and to emit
the text of your XML structure as you go...

This kind of parser is called Recursive Descent, and is easy to build
by hand. For example, this could be the interface to your parser:

Function ParseItems As Boolean
Function ParseItem As Boolean
Function ParseContentBlo ck As Boolean
Function ParseContent As Boolean
Function ParseAttributeO rItem As Boolean
Function ParseUnamedItem As Boolean
Function ParseNil As Boolean
Function ParseSubItem As Boolean
Function ParseName(ByRef Name As String) As Boolean

To give you a glympse of the kind of code involved, see how the
ParseContentBlo ck method could be written:

<aircode>
Function ParseContentBlo ck As Boolean
'Parses a '{', followed by an optional sequence
'of Content, followed by an '}'

If Not MatchToken("{") Then Return False
Do While ParseContent
Loop
RequireToken("} ")
Return True
End Function
</aircode>

The interesting thing is that only at specific places you'll need to
be concerned with actually emiting the data to your XML structure.
Say, for instance, in ParseAttributeO rItem, which will, as its name
says, recognize an attribute or an Item and generate the according
translation:

<aircode>
Function ParseAttributeO rItem As Boolean
'Will parse a Name followed by an '='
'followed by either a Literal or a ContentBlock

Dim Name As String
If Not ParseName(Name) Then Return False

RequireToken("= ")

If CurrentToken.Is Literal Then
'Creates an attribute
Emit("<attribut e name={0} value={1} />", _
Quoted(Name), Quoted(CurrentT oken.Value))
NextToken

ElseIf CurrentToken.Is OpenBrace Then
'ContentBlock starts with an open brace
'Create a new item
Emit("<item name={0}>", Quoted(Name))
ParseContentBlo ck
Emit("</item>")

Else 'Error
Throw new ParseError("Exp ected literal or '{'")

End If
Return True
End Function
</aircode>

As you can see, it's an almost literal translation of the production
content (a production is the set of rules describing a given non-
terminal) into code.

The thing with Recursive Descent Parsers is that they are, as the name
suggests, recursive. You saw, for example, that ParseAttributeO rItem
will call ParseContentBlo ck when it sees a '{' following the '=' char.
But if you look at the production for ContentBlock, you'll see that it
calls Content, which may call AttributeOrItem recursivelly. This is
the thing that allows the parser to keep track of the different
structures generated by the parsing process, and what differentiates
parsers from, say, Regular Expressions (which usually lack this
recursion power):

<aircode>
Function ParseContent As Boolean
'will parse an AttributeOrItem or an
'UnamedItem or a Nil or a SubItem,
'followed by a ','

Dimk Ok As Boolean
If CurrentToken.Is IdentifierOrOpe nBracket Then
Ok = ParseAttributeO rItem

ElseIf CurrentToken.Is OpenBrace Then
Ok = ParseUnamedItem

ElseIf CurrentToken.Is Nil Then
Ok = ParseNil

ElseIf CurrentToken.Is Literal Then
Ok = ParseSubItem

End If

If Ok Then RequireToken(", ")

Return Ok

End Function
</aircode>

Hope this gives you some ideas.

Regards,

Branco.
I want to make a program that reads the content of a LUA array save file..
More precicely a save file from a World of Warcraft plugin called
CharacterProfil er, which dumps alot of information about your characters
into that save file.

Anyhow, I want to extract a couple of lines of it and save it into a
database and I need help on figuring out a good way of reading the file.
The problem is that the file can look pretty different depending on the
proffessions and class of the characters etc. etc..

Is it possible to get an xml parser to read it or something?

I would appriciate all angles of approaching this..
Right now im thinking about just starting with getting rid of the stuff I
dont want in the file.. Like I only want the characters from a certain
server.. Trollbane. And I only want information about characters in the
guild Sacred Order Of Azeroth...
So if I just catch the part in the file where it starts with ["Trollbane"] =
{ and counts the '{' and '}' to get the one that ends the trollbane server..

Anyway, Im attaching the whole save file so that you can take a look at it..
Hope someone can give me some ideas.

EDIT: Aww, it was to big to send with..Im uploading it to a webspacehttp://www1.shellkonto .se/artix/CharacterProfil er.lua

Mar 21 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2931
by: Jaime Wyant | last post by:
*long post alert!* Can anyone give me some pointers on writing "self-updating" python programs? I have an application that is almost ready for beta testing. I want to be able to fix any bugs and push the updates out. I have a *very vague* idea of how to attack this. The client will have an auto-update feature that will hit the webserver via xml-rpc, asking for updates. The server responds, sending back any updated modules.
14
1625
by: Onideus Mad Hatter | last post by:
Well in theory it was a good idea: http://www.backwater-productions.net/_test_platform/game/index.html Press "4" to move left, press "6" to move right. The question remains though...is there some way of limiting onkeypress? Cause if you hold the key down, boy that's just all shades of unhappy right there. : char_l_img = 1;
11
2291
by: darcykahle | last post by:
I have stumbled upon an interesting issue with regard to compaction of an access frontend database which resides on a DFS target that utilizes FRS to mirror the sharepoint, and I was wondering if anyone knows a way to overcome it. For those who are unaware of DFS or FRS, DFS stands for Distributed File System, and basically involves "mounting" various sharepoints that reside on various computers underneath one special sharepoint. When...
10
2890
by: Tom | last post by:
I am looking for some ideas for how to design the layout of the form for data entry and to display the data for the following situation: There are many sales associates. A sales associate can work for multiple companies and work for multiple divisions within each company. Within each division he can work in multiple departments and within each department he can work with multiple groups. In each group he works on multiple projects. All the...
1
1051
by: RC | last post by:
-------------------------------------------------------------------------------- All, Need ideas on how to approach this: Have to compare account numbers in one table to account numbers in another table and if they exist in the second table The problem is the tables are in two separate databases (two different
10
2027
by: Luke Meyers | last post by:
So, just a little while ago I had this flash of insight. It occurred to me that, while of course in general there are very good reasons for the conventional two-file header/implementation separation for each C++ class, there are cases in which this paradigm contributes nothing and simply introduces extra boilerplate overhead. The particular case I have in mind is CppUnit tests. Each test header is only ever included by the...
43
2626
by: SLH | last post by:
hi people. im trying to validate input received via a text area on an ASP page before writing it to a database. i cant use client side javascript due to policy, so it all has to happen on the server. here is what i was trying, but pieces of it continue to break for one reason or another. the thinking behind this function was like this: if the input is less than 10 characters long, fail. if its 10 characters or greater, but it doesnt...
27
2175
true911m
by: true911m | last post by:
I would like to solicit your thoughts and ideas (code can come later) about how you would approach a project idea I just tossed together. I chose this as a testbed for me to play with objects, specifically multiple instances of a few specific objects, and as I thought about it, it raised a lot of questions about how to manage, contain, signal all of those objects that do almost the same thing at the same time. I want to build an OO bingo...
1
1528
by: Bob Alston | last post by:
Looking for design approach ideas for collecting data from multiple remote, standalone databases. I have built one of these in Access. Another I am told was built in Access. some others the language and database is unknown. These systems are all in small agencies which provide utility assistance to people who are having trouble paying their utility bills. A foundation wants to provide funds. However they want a consolidated...
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9531
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10459
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10237
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10187
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10018
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6795
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5578
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3735
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.