Thanks for the explanation.
# File lib/citrus.rb, line 99
99: def self.require(file, options={})
100: file += '.citrus' unless /\.citrus$/ === file
101: found = nil
102:
103: paths = ['']
104: paths += $LOAD_PATH unless Pathname.new(file).absolute?
If you look at line 103, it seems the paths is initialized with an
empty value,
then the "require" will run a unnecessary loop actually because paths
will be
the "" + the current $LOAD_PATH, I think this may be corrected like
below,
paths = []
or just remove the line 103, as $LOAD_PATH is an Array, so we can just
change 104 to,
paths = $LOAD_PATH unless Pathname.new(file).absolute?
The initialization of a new array to paths seems to be not needed.
On Dec 29, 2:26 pm, Michael Jackson <mjijack...@gmail.com> wrote:
> Hi Ken,
> The thing you need to remember is that although .citrus files look like
> Ruby, they're not really Ruby. They're actually a custom little language
> that looks a lot like Ruby. You can see the implementation for a `require`
> statement inside a .citrus file here:
> https://github.com/mjijackson/citrus/blob/master/lib/citrus/file.rb#L...
> It simply tries to use Kernel.require first, and falls back to
> Citrus.require if that fails. If both fail, the original LoadError is
> raised.
> --
> Michael Jackson
> @mjackson
> On Wed, Dec 28, 2011 at 9:56 PM, Ken <kenp...@gmail.com> wrote:
> > Hi,
> > In the following example copied from
> >https://github.com/mjijackson/citrus/blob/master/lib/citrus/grammars/...
> > require 'ipv4address' # (1)
> > require 'ipv6address'
> > grammar IPAddress
> > include IPv4Address
> > include IPv6Address
> > rule IPaddress
> > IPv4address | IPv6address
> > end
> > end
> > Is the line (1) should be written like
> > Citrus.require 'ipv4address'
> > Do I miss anything?- Hide quoted text -
> - Show quoted text -