[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [augeas-devel] NASL lens entry



Note that the Quote module has online documentation:

http://augeas.net/docs/references/lenses/files/quote-aug.html

and unit tests which provide great examples:

http://augeas.net/docs/references/lenses/files/tests/test_quote-aug.html


On Fri, Jan 10, 2014 at 7:44 PM, Raphaël Pinson <raphael pinson camptocamp com> wrote:
On Fri, Jan 10, 2014 at 3:59 PM, Tim Brigham <timbrigham gmail com> wrote:

>> I wanted to ask about how I'm handling one point in writing the lens for parsing my NASL files. 
>>
>> I'm using two cases for my end of line, those that end with a semicolon only and those that end with a closing parenthesis. e.g.
>>
>> let cparen      = del /\)/ ")"

>This is actually Util.del_str ")"

I'm aware that I duplicated the functionality of a couple of the Util.* statements. I was debugging some issues with my regexes and it was easier to have the exact values displayed on screen.  I'll get them converted back over to Util. statements eventually. :)

>> let semic       = Util.del_str ";"
>> let dquote      = Util.del_str "\""

>It is better now to rely on the Quote module for safe/ automatic quote management.

Can you please provide an example for this?  I've seen the quote module before don't have any experience with it. 

Sure. Here is your text parsed:

let entry =
  [ key Rx.word . Util.del_str "("
  . Quote.double
  . Util.del_str ");" . Util.eol ]

test entry get "script_copyright(\"This script is Copyright (C) 2004 Michel Arboi\");\n" = ?

$ augparse test.aug 
Test result: test.aug:8.0-.92:
  { "script_copyright" = "This script is Copyright (C) 2004 Michel Arboi" }

Would that do?


--
Raphaël Pinson
Infrastructure Developer & Trainer
+33 479 26 57 93

Camptocamp France
Savoie Technolac
BP 352
48, avenue du Lac du Bourget
73372 Le Bourget du Lac, Cedex
www.camptocamp.com



--
Raphaël Pinson
Infrastructure Developer & Trainer
+33 479 26 57 93
+33 781 90 00 79

Camptocamp France
Savoie Technolac
BP 352
48, avenue du Lac du Bourget
73372 Le Bourget du Lac, Cedex
www.camptocamp.com

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]