Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

how to write an abstract syntax tree code in Java for set of clauses

syntax

  • Please log in to reply
7 replies to this topic

#1 ama41900

ama41900

    CC Lurker

  • Just Joined
  • Pip
  • 4 posts

Posted 15 June 2010 - 07:17 AM

Hello,
I have a project about resolution for predicate logic and I have to wite codes in Java, So, firstly, I need to write an AST in Java for the resolution clasues.
Actually, I'm beginner in programming and I don't know how to wite an AST class for set of clauses.
If anyone has an experiecne with AST and logic, may help me?

Thanks in advance.
  • 0

#2 abzero

abzero

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 205 posts

Posted 15 June 2010 - 08:28 AM

AST are returned from parsers; do you need to write them by hand, if so you probably need to write the parser by hand to. If you can get a tool to do it for you try javacc or antlr (Antlr is more complex but more advanced I believe.)
  • 0

#3 ama41900

ama41900

    CC Lurker

  • Just Joined
  • Pip
  • 4 posts

Posted 15 June 2010 - 08:52 AM

hi abzero,
I talked to my supervisor about Antlr and he said that it will be more complex if i use it. he suggested me to write AST by hand and also parser, but firstly I have to start with AST and think about parser later
  • 0

#4 abzero

abzero

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 205 posts

Posted 16 June 2010 - 01:20 AM

Ok, I would suggest you first build a grammar for your predicate logic. Do you have examples of valid input's which you want to parse/represent? That would be the easist starting point. As at the moment you don't know what your AST should represent.
  • 0

#5 ama41900

ama41900

    CC Lurker

  • Just Joined
  • Pip
  • 4 posts

Posted 16 June 2010 - 11:59 AM

hi,
Thanks very much for your answers. I just want to know how to find an examples of valid input (number of clauses). my supervisor asked me to collect some examples but I don't know from where?? please bear with me because as I said I'm beginner in programming.

thanks again.
  • 0

#6 abzero

abzero

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 205 posts

Posted 16 June 2010 - 11:26 PM

Is this the kind of thing you're looking for?
Resolution Example and Exercises

One of the first steps in programming is understanding the problem domain, otherwise you don't know what your problem your trying to solve.
  • 0

#7 ama41900

ama41900

    CC Lurker

  • Just Joined
  • Pip
  • 4 posts

Posted 17 June 2010 - 04:29 AM

thank you for your help.
In my project i'm just working with clauses. So, if I collect differernt examples of clauses, I need to find an approprite grammar for my clauses??from where?

thanks you really helped me so much
  • 0

#8 abzero

abzero

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 205 posts

Posted 17 June 2010 - 11:17 PM

Once you have examples of clauses, you then can write a grammar for them. It's a lot easier that you think, but you need the examples first.
  • 0





Also tagged with one or more of these keywords: syntax

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download