• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Parsing scripts files through java

 
bhushan shelke
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

I'm working with embeded system, which has standard command set.

I need to store some of those commands in some kind of script file and then parse them sequentially(thr' java) and pass those commands to embeded system (thr' java).
Everything looks simple so far, but real challenge is handling conditional statements for e.g script/command file could be something like -

SET X
MOVETO 1000
X =GETPOSITION
IF(X<1000)
MOVETO (1000-X)

CAPTURE
....

This looks pretty much same as parsing grammar, how can this be achieved in java? Especially conditional parsing and then choosing appropriate path in script.

Thnx in advance.
 
Paul Clapham
Sheriff
Posts: 20986
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it is the same as parsing grammar. So that's what you will have to do.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15216
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are tools, for example JavaCC, that let you specify the grammar of the language and then generate Java source code that implements a parser for the language.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic