Comments on: Text parsing, formal grammars and BNF introduction http://eikke.com/text-parsing-formal-grammars-and-bnf-introduction/ 'cause this is what I do Tue, 04 Dec 2012 00:03:23 +0000 hourly 1 http://wordpress.org/?v=3.4.1 By: Abhay Joshi http://eikke.com/text-parsing-formal-grammars-and-bnf-introduction/comment-page-1/#comment-46638 Abhay Joshi Mon, 14 Mar 2011 18:03:53 +0000 http://eikke.com/text-parsing-formal-grammars-and-bnf-introduction/#comment-46638 I think tht the line "An integer is a non-zero digit, or a non-zero digits followed by an arbitrary amount of digits." should be modified as "An integer is a digit, or a non-zero digit followed by an arbitrary amount of digits." because your BNF looks like nzdigit ::= 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 digit ::= 0 | nzdigit digits ::= digit | digit digits integer ::= digit | nzdigit digits and hence 0 is a valid integer. I think tht the line
“An integer is a non-zero digit, or a non-zero digits followed by an arbitrary amount of digits.”
should be modified as
“An integer is a digit, or a non-zero digit followed by an arbitrary amount of digits.”
because your BNF looks like
nzdigit ::= 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
digit ::= 0 | nzdigit
digits ::= digit | digit digits
integer ::= digit | nzdigit digits
and hence 0 is a valid integer.

]]>
By: Divya http://eikke.com/text-parsing-formal-grammars-and-bnf-introduction/comment-page-1/#comment-38327 Divya Wed, 15 Sep 2010 13:11:41 +0000 http://eikke.com/text-parsing-formal-grammars-and-bnf-introduction/#comment-38327 Hi, I'm going to use BNF for the first time. Just going through online informations. Could you please tell me good docs if any. Thanks! Hi,
I’m going to use BNF for the first time. Just going through online informations.
Could you please tell me good docs if any.
Thanks!

]]>
By: preeti http://eikke.com/text-parsing-formal-grammars-and-bnf-introduction/comment-page-1/#comment-31296 preeti Sat, 30 Jan 2010 17:16:02 +0000 http://eikke.com/text-parsing-formal-grammars-and-bnf-introduction/#comment-31296 hi i need a source coding,to check the given expression in numbers is valid or not by using c programming hi i need a source coding,to check the given expression in numbers is valid or not by using c programming

]]>
By: sar http://eikke.com/text-parsing-formal-grammars-and-bnf-introduction/comment-page-1/#comment-4065 sar Fri, 23 May 2008 17:52:30 +0000 http://eikke.com/text-parsing-formal-grammars-and-bnf-introduction/#comment-4065 Hi, I'am a student , and as a project I have to write a grammar (LBNF one) -and it's ok for it-; then, I have to use the BNFC, and that's th e pb i.e. Idon't know how to use it. Please help me. and thanks a lot. Best regards. Hi,

I’am a student , and as a project I have to write a grammar (LBNF one) -and it’s ok for it-; then, I have to use the BNFC, and that’s th e pb i.e. Idon’t know how to use it.

Please help me. and thanks a lot.

Best regards.

]]>
By: ethana2 http://eikke.com/text-parsing-formal-grammars-and-bnf-introduction/comment-page-1/#comment-188 ethana2 Mon, 21 Jan 2008 08:45:27 +0000 http://eikke.com/text-parsing-formal-grammars-and-bnf-introduction/#comment-188 Lojban would have been perfect if it had a proper phonetic base. After I fork it and make the Best Language on Earth, we can avoid this nonsense ;) Lojban would have been perfect if it had a proper phonetic base.
After I fork it and make the Best Language on Earth, we can avoid this nonsense ;)

]]>
By: RubenV http://eikke.com/text-parsing-formal-grammars-and-bnf-introduction/comment-page-1/#comment-178 RubenV Sun, 20 Jan 2008 19:52:46 +0000 http://eikke.com/text-parsing-formal-grammars-and-bnf-introduction/#comment-178 Nicolas: You're cheating there by combining recursion and regular expressions :-). Pure regular expressions can't do that. Recursion is actually what sets regular languages and context free grammars apart. Nicolas: You’re cheating there by combining recursion and regular expressions :-) . Pure regular expressions can’t do that. Recursion is actually what sets regular languages and context free grammars apart.

]]>
By: Nicolas http://eikke.com/text-parsing-formal-grammars-and-bnf-introduction/comment-page-1/#comment-177 Nicolas Sun, 20 Jan 2008 18:30:02 +0000 http://eikke.com/text-parsing-formal-grammars-and-bnf-introduction/#comment-177 no one in particular: indeed... I translated it somewhat badly. So to be correct: <ul><li>whole_number ::= digit | nzdigit digits</li> <li>sign ::= "-" | "+" | ""</li> <li>integer ::= sign whole_number</li></ul> Ruben: out of my head, if input is 'foo(bar(baz)bat)', can't you do something like <pre>parts = [] regex = '^([.^(]*)[\(([.^)]*)\)]*(.*)$' def parse(s): parts = regex.parse(s) parts.append(parts[0]) for i in range(1, len(parts)): parse(parts[i]) parse(s)</pre> no one in particular: indeed… I translated it somewhat badly. So to be correct:

  • whole_number ::= digit | nzdigit digits
  • sign ::= “-” | “+” | “”
  • integer ::= sign whole_number

Ruben: out of my head, if input is ‘foo(bar(baz)bat)’, can’t you do something like

parts = []
regex = '^([.^(]*)[\(([.^)]*)\)]*(.*)$'

def parse(s):
    parts = regex.parse(s)
    parts.append(parts[0])
    for i in range(1, len(parts)):
        parse(parts[i])

parse(s)
]]>
By: RubenV http://eikke.com/text-parsing-formal-grammars-and-bnf-introduction/comment-page-1/#comment-176 RubenV Sun, 20 Jan 2008 17:46:42 +0000 http://eikke.com/text-parsing-formal-grammars-and-bnf-introduction/#comment-176 Nicolas: Try expressing a language which recognizes balanced brackets, which can be arbitrarily nested using a regular expression. Fairly trivial in BNF, impossible to implement using traditional regular expressions. Nicolas: Try expressing a language which recognizes balanced brackets, which can be arbitrarily nested using a regular expression.

Fairly trivial in BNF, impossible to implement using traditional regular expressions.

]]>
By: no one in particular http://eikke.com/text-parsing-formal-grammars-and-bnf-introduction/comment-page-1/#comment-175 no one in particular Sun, 20 Jan 2008 17:46:14 +0000 http://eikke.com/text-parsing-formal-grammars-and-bnf-introduction/#comment-175 For the record, note that you've described the whole numbers, not the integers, because integers include negative numbers. (I'm not trying to be annoying, but I figured it was worth pointing out. Thanks for the interesting read!) For the record, note that you’ve described the whole numbers, not the integers, because integers include negative numbers.

(I’m not trying to be annoying, but I figured it was worth pointing out. Thanks for the interesting read!)

]]>
By: Mattias Bengtsson http://eikke.com/text-parsing-formal-grammars-and-bnf-introduction/comment-page-1/#comment-173 Mattias Bengtsson Sun, 20 Jan 2008 14:32:19 +0000 http://eikke.com/text-parsing-formal-grammars-and-bnf-introduction/#comment-173 I've been using BNFC (BNF Converter) for some compiler construction courses at school. I think it is a really neat project. It can generate Java, Haskell and C++-parsers. I'm not sure if it can output Python parsers though. I’ve been using BNFC (BNF Converter) for some compiler construction courses at school. I think it is a really neat project. It can generate Java, Haskell and C++-parsers. I’m not sure if it can output Python parsers though.

]]>