9 Replies - 736 Views - Last Post: 24 December 2012 - 08:36 PM Rate Topic: -----

Poll: problem with Lex. (1 member(s) have cast votes)

What Lex program would you suggest?

  1. YACC (0 votes [0.00%])

    Percentage of vote: 0.00%

  2. ANTLR (1 votes [100.00%] - View)

    Percentage of vote: 100.00%

  3. JavaCC (0 votes [0.00%])

    Percentage of vote: 0.00%

Vote Guests cannot vote

#1 shandan97  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 23-December 12

problem with Lex.

Posted 23 December 2012 - 07:36 PM

Hello, I am having little issues with learning Lex. I am trying to create a programming language, but I dont know where to start as far as writing the grammar. I have looked into progams such as ANTLR, YACC, and JavaCC. But I don't really get where they are getting all the code from. I also kind of dont fully understand what writing lex does, as far as declaring a programming language's grammar. Also, by Grammar, they mean the Syntax of the programming language correct?

NOTE: I am just trying to create a simple programming language, nothing too sophisticated..

Is This A Good Question/Topic? 0
  • +

Replies To: problem with Lex.

#2 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2133
  • View blog
  • Posts: 3,269
  • Joined: 21-June 11

Re: problem with Lex.

Posted 24 December 2012 - 02:40 AM

If you're using Lex (or a compatible implementation like flex), you should use YACC (or a compatible implementation like bison) as your parser generator. The other two come with their own lexers and won't be useful for working with Lex (hell, javacc doesn't even generate C code).
Was This Post Helpful? 1
  • +
  • -

#3 shandan97  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 23-December 12

Re: problem with Lex.

Posted 24 December 2012 - 07:57 AM

View Postsepp2k, on 24 December 2012 - 02:40 AM, said:

If you're using Lex (or a compatible implementation like flex), you should use YACC (or a compatible implementation like bison) as your parser generator. The other two come with their own lexers and won't be useful for working with Lex (hell, javacc doesn't even generate C code).


Ah, glad to see you seen this! And I see, I have ANTLR, does that work? And I'll look at YACC. I've been reading on EBNF, and I'm not quite understanding some of it.
If you don't mind, I have some questions, you can contact me at <Removed>, you'll probably get the quickest replies out of me that way. Either way is fine with me. I just need some questions answered for me to fully understand this.

Thanks!

Shandan

This post has been edited by macosxnerd101: 24 December 2012 - 08:39 PM
Reason for edit:: Removed email per site policies. Please keep all work via the forums.

Was This Post Helpful? 0
  • +
  • -

#4 shandan97  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 23-December 12

Re: problem with Lex.

Posted 24 December 2012 - 08:07 AM

View Postsepp2k, on 24 December 2012 - 02:40 AM, said:

If you're using Lex (or a compatible implementation like flex), you should use YACC (or a compatible implementation like bison) as your parser generator. The other two come with their own lexers and won't be useful for working with Lex (hell, javacc doesn't even generate C code).


Also, I thought, I'd just might add, that I'm going to be keeping a blog on my experiences of creating a programming language, so if you're any interested you might wanna check it out!
Was This Post Helpful? 0
  • +
  • -

#5 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 7884
  • View blog
  • Posts: 13,396
  • Joined: 19-March 11

Re: problem with Lex.

Posted 24 December 2012 - 08:12 AM

So what's the hook? What's the elevator speech on your language?
Was This Post Helpful? 0
  • +
  • -

#6 shandan97  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 23-December 12

Re: problem with Lex.

Posted 24 December 2012 - 08:23 AM

View Postjon.kiparsky, on 24 December 2012 - 08:12 AM, said:

So what's the hook? What's the elevator speech on your language?


For now, I'm just looking to tinker around with it. I'll probably get more serious about it as I learn and get better.
Was This Post Helpful? 0
  • +
  • -

#7 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2133
  • View blog
  • Posts: 3,269
  • Joined: 21-June 11

Re: problem with Lex.

Posted 24 December 2012 - 10:02 AM

View Postshandan97, on 24 December 2012 - 03:36 AM, said:

But I don't really get where they are getting all the code from.


Can you explain what you mean by that exactly? Where who is getting which code from?

Quote

Also, by Grammar, they mean the Syntax of the programming language correct?


Yes, a grammar is a description of the syntax of a programming language.

View Postshandan97, on 24 December 2012 - 03:57 PM, said:

Ah, glad to see you seen this! And I see, I have ANTLR, does that work? And I'll look at YACC.


If you don't have to use Lex, ANTLR is a perfectly fine option. In fact I'd say it's preferable to lex+yacc / flex+bison.
Was This Post Helpful? 0
  • +
  • -

#8 shandan97  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 23-December 12

Re: problem with Lex.

Posted 24 December 2012 - 10:19 AM

View Postsepp2k, on 24 December 2012 - 10:02 AM, said:

View Postshandan97, on 24 December 2012 - 03:36 AM, said:

But I don't really get where they are getting all the code from.


Can you explain what you mean by that exactly? Where who is getting which code from?

Quote

Also, by Grammar, they mean the Syntax of the programming language correct?


Yes, a grammar is a description of the syntax of a programming language.

View Postshandan97, on 24 December 2012 - 03:57 PM, said:

Ah, glad to see you seen this! And I see, I have ANTLR, does that work? And I'll look at YACC.


If you don't have to use Lex, ANTLR is a perfectly fine option. In fact I'd say it's preferable to lex+yacc / flex+bison.


Well, I've looked at multiple examples of programming language grammar, but I don't really get it. I think what I really need explained is what a lex token is and what they do. That's what I'm having the most issues with. And I'm probably going to try YACC and see what that is like, thanks for the suggestion.
Was This Post Helpful? 0
  • +
  • -

#9 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2133
  • View blog
  • Posts: 3,269
  • Joined: 21-June 11

Re: problem with Lex.

Posted 24 December 2012 - 10:33 AM

View Postshandan97, on 24 December 2012 - 06:19 PM, said:

I think what I really need explained is what a lex token is and what they do.


Have you read my response in your other thread?
Was This Post Helpful? 0
  • +
  • -

#10 blackcompe  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1155
  • View blog
  • Posts: 2,536
  • Joined: 05-May 05

Re: problem with Lex.

Posted 24 December 2012 - 08:36 PM

Quote

Well, I've looked at multiple examples of programming language grammar, but I don't really get it. I think what I really need explained is what a lex token is and what they do. That's what I'm having the most issues with. And I'm probably going to try YACC and see what that is like, thanks for the suggestion.


If that is the case, you need study a little theory before delving into tools. There are plenty of lectures, books, etc. for learning compiler/language design. The dragon book is a good starting place. A gentler introduction is Programming Language Pragmatics. Also check out my tutorial.

As far as picking a tool, I recommend Flex/Bison for C/C++ or JLex/CUP for Java.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1