Link to home
Start Free TrialLog in
Avatar of fab1970
fab1970

asked on

How to parsing simple scripts

I need to build a "simple" script parser: an app receive strings from a RS232 connection.
In a text file i have some "expressions" to execute, the app reads these expressions and return via RS232 the correct answer.
I put here a starting idea of what i think about these "expressions":

1)
IF "the input string must match exactly this string, no care of capitalization"
THEN "This string wil be sent via RS232"
ELSE "This is another string that wil be sent via RS232"
END

2)
IF CAPS "This String MUST Match Capitalization"
THEN ""This string wil be sent via RS232"
END

2)
IF CONTAINS CAPS "This string Is CONTAINED somewhere in the input string, Capitalization match also"
THEN
    IF "a test depending on the previous IF test"
    OR "another string"
    THEN "ok"
    ELSE "No"
    END
ELSE "Another result"
END

Well, i hope you can uderstand what i mean.
I'm searching for a sample, a link, something that make me able to build the "expression" parser, converting the lines readed from the text file in a functon that works.
Thnkx
Avatar of Marv-in
Marv-in

here is a link with examples of the various string functions in VB
http://www.officecomputertraining.com/vbtutorial/tutpages/page19.asp

if you would like more specific info let me know
Avatar of fab1970

ASKER

Marv,
i know the strings functions in vb, what i need is a way to read the examples i've wrote in the question from a text file in a function that, given an input string, do the comparisons.
In other words i need a custom-script interpreter...
Ii's hard to explain in a foreign language, i'm sorry.
Avatar of Ark
Hi
If you're speaking about 'script', did you thought about 'tags'? You can put smth like 'tags' in the beginning of your strings in a file, like:
[1] First type of string 'optionally end of tag mark [/1], or just [br] or vbCrLf
[2] Second type of string 'optionally end of tag mark [/1], or just [br] or vbCrLf
...etc
Now you can just read a tag and perform action according this tag
I think I understand - you want to parse a file that is actually formatted like what you posted. If that is the case this could take some work.

if you want an advanced example of a parsing engine - this is it
http://www.devincook.com/goldparser/engine/index.htm#Engine-DLL

this example includes grammer definitions and lots of other good stuff - plus its free =]
Avatar of fab1970

ASKER

Marv,
you've right understood me.
I've got a look at the link you tell me. The Gold Engine i'ts a huge stuff for the "little" thing i need... i need some time to understand the Gold Engine.
Anyway, it's a step in the right direction. If you have some simpler example, or some tips for me, you're welcome.

;)
ASKER CERTIFIED SOLUTION
Avatar of Marv-in
Marv-in

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fab1970

ASKER

Well, it's a starting point. I now have an idea of what to do. Thanks, Marv.