Oni Central Forum

A forum for the Oni community

You are not logged in.

#1 18/11/14 15:27

Dirk Gently
Member
From: Boston, MA
Registered: 12/6/09
Website

BSL Validator

Over the past few days i've been playing around with BSL and decided to write a validator tool for it. The tool is still in the works and can currently parse .bsl files, the syntax validation isn't complete yet.

bad things:
* BSL has no formal grammar, and as far as i can tell it wouldn't be possible to write a syntactical grammar for the language as it is without imposing some "standards"
* even with a formalized grammar, the language can do a lot less than it claims to be able to do, while code can be validated, it may not execute safely inside of Oni's parsing engine
* as of right now I am NOT supporting multi-line function declarations, e.g.:

// NOT SUPPORTED
func void foo(
    string n,
    int a)

// SUPPORTED
func void foo(string n, int a)


good things:
* full list of globally defined functions and variables that are initialized and validating the syntax of using them is in the works
* I am reverse engineering how Oni parses the script files, to try to recreate process as closely as possible

As mentioned i am writing this in python; it is just a script to run, nothing to compile. I have got most if not all of the parsing bugs dealt with by now, so I just have to write the rest of the validation code now. I'm only using stock scripts for testing right now, but wanted to see if there was anything i missed in the parser so i am posting about it so you can play with it.

usage:

$ python bsl.py /path/to/some/file.bsl

Note: I don't know about running python on windows, i know it is possible but I don't think it ships with windows natively? This has no specific modules or requirements so you should be able to run it on anything given python is installed.

github repo

Offline

#2 18/11/14 16:13

paradox-01
Member
From: Germany
Registered: 14/1/07

Re: BSL Validator

Installed python from...
https://www.python.org/downloads/release/python-342/


Then downloaded your scripts, put them and a bsl into the python34 folder and used the cmd.

cd C:/Python34

C:\Python34>python bsl.py compound.bsl
File: "bsl.py", line 32
  global GLOBAL_FUNCTIONS;

IndentationError: expected an indented block

I've 0 experience with python nor the time to really try to learn it. But I'm still curious enough to try this out.
So... more indented blocks please? ^_^

Offline

#3 18/11/14 17:04

Dirk Gently
Member
From: Boston, MA
Registered: 12/6/09
Website

Re: BSL Validator

That is actually a really good questions because as far as I am aware this *should* work. I am using Python 2.7.5, so maybe try using a 2.7.x installer instead because there might be a difference in how the syntax works.

Offline

#4 18/11/14 19:55

Dirk Gently
Member
From: Boston, MA
Registered: 12/6/09
Website

Re: BSL Validator

Also how did you download the code? I double checked it and there shouldn't be any problems with running this with Python 3.x. Did you download a zip or clone the repo? Whitespace is important so if any of that breaks the code won't run.

Offline

#5 19/11/14 2:13

paradox-01
Member
From: Germany
Registered: 14/1/07

Re: BSL Validator

I downloaded via copy-paste (I overlooked the buttons).
This time I used the zip download and got this far:

C:\Python34>python bsl.py compound.bsl
  File "bsl.py", line 143
    print 'Invalid name string';
                              ^
SyntaxError: Missing parentheses in call to 'print'

Will later try an older python.

Offline

#6 19/11/14 12:07

Dirk Gently
Member
From: Boston, MA
Registered: 12/6/09
Website

Re: BSL Validator

you are going to need all 3 files and either checked out from a git clone or from the zip. As far as i can tell this should run fine on a newer version of python, it does for me and a friend of mine, so I am not sure why it wouldn't work for you.

Offline

#7 19/11/14 13:50

paradox-01
Member
From: Germany
Registered: 14/1/07

Re: BSL Validator

Yay.
Installed python v2.7.8, works now. smile

python_compound_test.png

Offline

#8 19/11/14 16:14

Dirk Gently
Member
From: Boston, MA
Registered: 12/6/09
Website

Re: BSL Validator

nice! ok, i'll see about getting better support for python 3 then, until then it requires python 2.7.x.

Offline

#9 29/12/14 10:26

Dirk Gently
Member
From: Boston, MA
Registered: 12/6/09
Website

Re: BSL Validator

Posting an update to this:

After some consideration of how to solve some of the issues with parsing the scripts accurately to the way Oni does I decided to rewrite this in C. It is in the same repo as before, so see the original post for the link.

I've got the evaluation part working and the code generates IR for the scripting language, I am still working on hooking that up to an execution engine to parse and evaluate the logic. If you are working with scripts for Oni then this will only be useful to evaluating if script logic is syntactically correct. Since the scripting command evaluation happens internally (within Oni's code) I don't think it is feasible to make it also try to replay logic that depends on commands defined within the game.

However, I would like to use this to explore the possibility of creating a library for running commands with it and trying to flesh out some of the lesser documented parts of the scripting engine and language behavior.

Offline

#10 29/12/14 21:37

Gumby
Member
From: Seattle, WA, USA
Registered: 30/8/07

Re: BSL Validator

If you have it hooked up to an IR, that makes it easier if someday if lua is hooked in instead of BSL.


Iritscen: roll
Iritscen: it's amazing this program even works
Gumby: i know
Iritscen: and that statement applies to my code, not just yours

Offline

#11 30/12/14 7:42

Dirk Gently
Member
From: Boston, MA
Registered: 12/6/09
Website

Re: BSL Validator

Yep, from what I can see through RE of the binary it just gets tokenized then executed. My code is parsing it and generating an IR state then performing execution/evaluation. Once I can get the execution part handled then I could probably refactor the raw->IR process a bit.

Offline

Board footer

Powered by FluxBB