Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 2 [3] 4

Author Topic: RawScript: Test Released! Check first post.  (Read 2931 times)

madk

  • Bay Watcher
    • View Profile
    • pineapplemachine
Re: RawScript
« Reply #30 on: June 29, 2010, 01:53:56 pm »

Yes. I have it working now. I also added several things to make math and stuff that much less frustrating for the modder to work with, including ditching the confusing [? (...) ] for [# (...) ] as an option, and even better, ( (...) ). [A (...) ] is for performing absolute value on the operation.

Here are the current operators, keeping them as a single character is a lot easier to implement than full keywords, so deal with it. :P

Standard operators +-*/
Exponential operators ^ (to power) and V (root)
Bitwise logic operators & (and) | (or) X (xor) U (nand) N (nor) and Z (xnor)
Bitshifting operators L (shift left) and R (shift right)
Comparison operations = > and <
Modulo operation M (would have been %, but then the stuff that recognizes variables would screw up.)

I just need to find out why the floating point stuff isn't working (it's insisting on removing the decimals for some reason) and make sure the standard input works OK and I'll give a release. It won't be useful yet, but it'll be better than having no proof of progress save these forum posts.


Oh, and I have yet to find out if my xor and xnor operations work properly. I had to hack them up with not ands, because the language I'm using doesn't have xor readily available as an operation.
« Last Edit: June 29, 2010, 01:55:32 pm by madk »
Logged

madk

  • Bay Watcher
    • View Profile
    • pineapplemachine
Re: RawScript
« Reply #31 on: June 29, 2010, 02:40:20 pm »

Oh, lovely. Something about strings is still bugged.  :-\

madk

  • Bay Watcher
    • View Profile
    • pineapplemachine
Re: RawScript
« Reply #32 on: June 29, 2010, 02:50:52 pm »

Alright, only two bugs left to tackle. Xor works, and I'm very happy about that.

Code: [Select]
define %test% { "       this is a test." }
define %roar% { "hear me roar." }
define %both% { %test% %roar% }
output %both%


define %one% {1}
define %two% { (8^ (9/3)) }
output %two%


define %zero% { 0 }
output [& %one%%zero% ]
define %ten% { %one%%zero% }
output %ten%
output [& "zero  " + (%one%X%one%) ]

The bugs are:
"       this is a test." becomes "this is a test." and "zero " becomes "zero". This should only be a matter of finding out where I'm removing these quotes prematurely by mistake.
And I still haven't looked into the floating points not working. For example, "define %two% { (8^ (9/3)) }" (512) works beautifully, while "define %two% { (8^ (3/9)) }" (2) does not.



EDIT: Ah, no, the string bug is rather major. I guess I had missed making the arithmatic parser able to recognize that "1+1" is a string as opposed to 1+1 being an equation. This lack of recognition of quotes in this particular section of code is the root of all the problems, though, so fixing this should correct the issues across the board.
« Last Edit: June 29, 2010, 03:02:17 pm by madk »
Logged

madk

  • Bay Watcher
    • View Profile
    • pineapplemachine
Re: RawScript
« Reply #33 on: June 30, 2010, 05:51:38 am »

A fresh look in the morning:

I wrote a general parsing function ages back that I've used in programs innumerable to this day. Its purpose is very simple: if you have a line of text formatted like "command argument,argument //oh hey, comment!" it recognizes it and makes it generally easier to keep the code that processes it a little more consistent. Problem is, I forgot that I wrote it to realize that key chracters inside of quotes don't count. But it gets rid of those quotes in the output, too. There the issue lies, since I need these quotes to properly parse the string equations and things, but I'm still rather confused as to exactly why it's still happening after I thought I had changed it.

And the floating points are only because I fogot to declare one variable as a double instead of an int. Silly me.

Release get, as soon as these two things are fixed. (I hope)

madk

  • Bay Watcher
    • View Profile
    • pineapplemachine
Re: RawScript
« Reply #34 on: June 30, 2010, 07:45:59 am »

Ahar, release!

At the moment, it can't do anything to the raws, I haven't worked on that yet since this rewrite. The code will be easy to transfer from the previous work, though.

Please read the comments in the code file to get an idea of what's going on.

Download

Conditional statements and loops are probably next. Shouldn't take long, I've already got the groundwork implemented in the parsing loop.
« Last Edit: June 30, 2010, 07:47:47 am by madk »
Logged

madk

  • Bay Watcher
    • View Profile
    • pineapplemachine
Re: RawScript: Test Released! Check first post.
« Reply #35 on: June 30, 2010, 08:11:32 am »

Ah, I forgot to fix one thing before I provided that link. The 10 example is broken atm.

madk

  • Bay Watcher
    • View Profile
    • pineapplemachine
Re: RawScript: Test Released! Check first post.
« Reply #36 on: June 30, 2010, 09:16:12 am »

I'm moving on to conditional statements.

Also, I added = to compare strings as equal, and < and > for length comparisons. Also added u[pper]case, l[ower]case, p[roper]case, and i[nvert]case <%variable%> to change the cases of letters within strings. (These are not in the download. Next release will be after conditional statments and loops. Probably functions, too.)

EDIT: Modulo, too, now. It gives you the difference in length.

Anyone thinking of operators I may have missed?
« Last Edit: June 30, 2010, 09:18:33 am by madk »
Logged

ilfirin

  • Escaped Lunatic
    • View Profile
Re: RawScript: Test Released! Check first post.
« Reply #37 on: June 30, 2010, 09:57:42 am »


Anyone thinking of operators I may have missed?

Can you create pointers yet?   ;D
Logged

madk

  • Bay Watcher
    • View Profile
    • pineapplemachine
Re: RawScript: Test Released! Check first post.
« Reply #38 on: June 30, 2010, 10:02:55 am »

It's less of a language than an interpreter. So no. :P

I can do something with it if you think it'll actually have a use, though. (Even though half the things in there are only there because it took a couple lines of code, I doubt anybody will ever use some of these features)


EDIT: Hm, I just realized I have no support for arrays. I think I should probably do that.

bdog

  • Bay Watcher
    • View Profile
Re: RawScript: Test Released! Check first post.
« Reply #39 on: June 30, 2010, 10:35:37 am »


Anyone thinking of operators I may have missed?

Can you create pointers yet?   ;D

As for operators: as i think now "not equal" (others like >= or <= for numerical comparision can be substituted with normal > and < so they not that needed)

For pointers: heck, I think that I had good imagination but still don't know how would you make use of them here ;) but the more the merrier :)

===
On a side note: yesterday when I had a little free time I made something that you could call bridge between C# and JavaScript (well, its using already working solutions so it was like connecting bricks).
I made it just for fun and its still not quite working with raws (well, working but not as I would like to)
Engine allows you to use .net code IN javascript code (classes, objects etc)
Spoiler (click to show/hide)
With JS one could do almost everything on raws. Problem is in reading raw txt and parsing them into arrays (I'm using regex atm to get all tags and a couple of other regexes to sort them somehow) and saving them back.
Question: whitespaces in raw files are there only for readability or are they a must?
Logged

madk

  • Bay Watcher
    • View Profile
    • pineapplemachine
Re: RawScript: Test Released! Check first post.
« Reply #40 on: June 30, 2010, 10:57:15 am »

Readability.

Here's the relevant BlitzMax code for my parsing of the raws file.

Every raw object is stored with an object (the [OBJECT:___] tag), what file it originally came from, and all of the tokens are stored in sequence in a linked list.

Raw object "obj" object.

EDIT: ack, the codebox takes away tabs. You get spoilers instead. :P

Spoiler (click to show/hide)

Here's where most of the action takes place:
Spoiler (click to show/hide)

Here's some miscellaneous token parsing code:
Spoiler (click to show/hide)


Maybe it'll be of some help to you. Keep in mind that it's old, mostly untested, and I know there are at least a couple bugs. So don't rely on it too much.

Also, as for a not equal operator, that's something I should have thought of myself. I'll be putting that in, too, then. Soon as I've got the arrays working.
« Last Edit: June 30, 2010, 10:59:33 am by madk »
Logged

soul4hdwn

  • Bay Watcher
  • make due with what you have
    • View Profile
Re: RawScript: Test Released! Check first post.
« Reply #41 on: June 30, 2010, 06:29:50 pm »

*patently waits for completion*
« Last Edit: June 30, 2010, 06:31:21 pm by soul4hdwn »
Logged

Normandy

  • Bay Watcher
    • View Profile
Re: RawScript: Test Released! Check first post.
« Reply #42 on: June 30, 2010, 10:13:17 pm »

I think you should look into regexes (regular expressions) before continuing any further, they are the standard for text processing: http://en.wikipedia.org/wiki/Regex. There are many libraries for dealing with regexes in a simple fashion, so it's more of a question that you don't design a syntax which interferes with regex syntax (which unfortunately, you currently are) rather than any actual code work.
Logged

madk

  • Bay Watcher
    • View Profile
    • pineapplemachine
Re: RawScript: Test Released! Check first post.
« Reply #43 on: July 01, 2010, 05:36:54 am »

I'm going on a trip until Tuesday now, so if I'm near a computer I'll try and do something, but GameJolt has its indie demake competition this week, so that'll have to be my priority until the 8th. :P

As for Regex, down with standards, up with working your rear off with equivalent but horribly complxex systems!!
Yeah, my system can basically do all regex can, but not as efficiently.

Star Weaver

  • Bay Watcher
    • View Profile
Re: RawScript: Test Released! Check first post.
« Reply #44 on: July 01, 2010, 07:31:10 am »

As for Regex, down with standards, up with working your rear off with equivalent but horribly complxex systems!!
Yeah, my system can basically do all regex can, but not as efficiently.
:o

Cool. Hopefully by the time you get back I'll have had the time and brain power to try converting things to your syntax :D.
Logged
Pages: 1 2 [3] 4