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

Re: [augeas-devel] NASL lens entry



>> 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. 

>> let comma       = del /,/ ","
>> let colon       = del /:[ \t]*/ ": "
>> let eol         = del /[ \t]*\n/ "\n"

>It's good practice tous Util.eol here

>> let del_opt_ws = del /[ \t]*/ ""
>> let equal       = del /[ \t]*=[ \t]*/ "="

>this is Sep.space_equal

>> let oparen      = del /\(/ "("
>>
>> let cparen_entry (kw:string) = [ del_opt_ws .  key kw . oparen . value_to_cparen . cparen . semic . eol   ]

>From your example below, it seems like you'd rather want a value_to_dquote.

>> let semic_entry (kw:string) = [  del_opt_ws . key kw  . equal .  value_to_semic .  semic . eol ]
>>
>> This works perfectly until I run into something where I have an embedded closing parenthesis in a given line, e.g
>>
>>
>>  script_copyright("This script is Copyright (C) 2004 Michel Arboi");
>>
>>
>> My thought is something like this should work to generalize it but I'm not sure how to define value_to_something. 
>>
>> let refined_entry (kw:string) = [ del_opt_ws . key kw . ( oparen | equal ) . value_to_something . cparen{0,1} . semic . eol  ]
>>
>> The (oparen|equal) comes back with 
>> exception: overlapping lenses in tree union.put
>>     Example matched by both:
>>     First lens: lens/nasl.aug:24.14-.26:
>>     Second lens: lens/nasl.aug:23.13-.36:

>see my comment above on value_to_dquote. Again, the Quote module can help you here.



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