Forums | Admin

Discussion Forums: help

Start New Thread Start New Thread

 

By: Ben Hellerstein
RE: Possible bug [ reply ]  
2009-11-16 21:56
You're welcome. BTW this is a great library.

By: Mushfeq Khan
RE: Possible bug [ reply ]  
2009-11-15 06:20
I think it's a bug. Thanks for bringing it to my attention.

Mushfeq.

By: Ben Hellerstein
RE: Possible bug [ reply ]  
2009-11-15 01:25
Small error in my example: "for_symbol('OptionalBar')" should be "for_symbol('OptionBar')"

By: Ben Hellerstein
Possible bug [ reply ]  
2009-11-15 01:12
The following grammar returns a ParseErrorResult (unexpected token "_End_") when you try to parse "hello foo"

========= BEGIN CODE ========
require 'dhaka'
require 'pp'

class LexerSpec < Dhaka::LexerSpecification
%w(hello foo bar).each{|v| for_pattern(v){ create_token(v) } }
for_pattern('\s+'){ }
end

class Gram < Dhaka::Grammar
for_symbol(Dhaka::START_SYMBOL_NAME){ start_1(%w| hello Foo OptionBar |) } # change "Foo" to "foo" or "OptionBar" to "Option"and this grammar successfully parses "hello foo"
for_symbol('Foo'){ foo_1(%w| foo |) }
for_symbol('OptionalBar'){ bar_t(%w| Option |) }
for_symbol('Option') do
option_exists %w| Bar |
option_does_not_exist %w| |
end
for_symbol('Bar'){ bar_1(%w| bar |) }
end

pp Dhaka::Parser.new(Gram).parse(Dhaka::Lexer.new(LexerSpec).lex("hello foo"))
========= END CODE ========

However, I have verified this grammar should parse successfully:

1. Go to http://smlweb.cpsc.ucalgary.ca/start.html.

2. Enter the following into the text field:
Start -> hello Foo OptionBar.
Foo -> foo.
OptionBar -> Option.
Option -> Bar
|.
Bar -> bar.

3. Click "View Vital Statistics"
4. Click "check to see if certain sentences are in the language"
5. Type "hello foo" and press enter


Is this a bug? Or have I mis-specified the grammar? I tried experimenting with Dhaka::END_SYMBOL_NAME without luck. Any help would be welcome. Thanks!

-Ben