[ragel-users] Why not prepend a prefix to variables used by ragel?

Mark Olesen Mark.Olesen at esi-group.com
Sat Feb 23 12:33:15 UTC 2019


I'm one of the first ones to complain about bad variable names etc., but 
never had a problem with the ragel names at all. The names are short 
enough to manage, never conflict with my own variable names which tend 
to be much longer anyhow. The places where I need the ragel parsing 
tends to be of limited code scope, so there is no real danger of 
stomping on other variables either.

For what it's worth, you may find some ideas from the following grammars
1. a C/C++ #include dependency scanner with hashing that is usually 
about 30-40% faster than using cpp.

Machine definition at line 310. The processing itself at line 370, 
encapsulated in a special-purpose method.

https://develop.openfoam.com/Development/OpenFOAM-plus/blob/master/wmake/src/wmkdepend.rl


2. a lexer for parsing STL ascii files.
Which I guess should probably be rejigged to be a state machine instead.
Here again the details of the parser are isolated in an execute() method.

https://develop.openfoam.com/Development/OpenFOAM-plus/blob/master/src/fileFormats/stl/STLAsciiParseRagel.rl


/mark


On 2/23/19 1:59 PM, Adrian Thurston wrote:
> Sorry but creating an unnecessary three-year countdown to breaking all 
> ragel programs ever written spectacularly fails cost-benefit analysis 
> over my finite time and energy on this planet.
> 
> I do not know how many users there are.
> 
> Lexical analysis is not the primary function of ragel. It's something it 
> does. It's intended for expressing a parser as a single regular (ish) 
> grammar.
> 
> On 2019-02-23 14:12, Peng Yu wrote:
> 
>> This can be easily solved but adding a command line option to enable 
>> such prefixes and the date the prefixes will be enforced (say in 3 
>> years). So people can have time to migrate their ragel code. This kind 
>> of things has been done all the time. I don't think it should be an 
>> excuse not make the variable name more readable. "access" can solve 
>> the readability problem, but it also uses an extra structure which 
>> changes the meaning of the code. I will check "variable" later.
>> BTW, how many uses of ragel anyway? It seems to have a far less user 
>> base than flex. My impression is that people uses it because it can 
>> offer something flex does not offer. However, flex can already solve a 
>> lot of lexing problems. So there will be much less users use ragel 
>> than flex. This can be shown by the numbers of questions on stack 
>> overflow and the numbers of projects on github.
>>
>> On Sat, Feb 23, 2019 at 3:52 AM Adrian Thurston <thurston at colm.net 
>> <mailto:thurston at colm.net>> wrote:
>>
>>     You can use the variable and access statements (section 5 of the
>>     manual).
>>
>>     Changing the default behaviour at this point would break every ragel
>>     program out there and that's not something I'm interested in doing.
>>
>>     On 2019-02-22 21:23, Peng Yu wrote:
>>     > The variables mentioned in section 5.1 "Variables Used by Ragel"
>>     > manual are very much like common names. It will be confusing to look
>>     > at ragel code written in this way. Why not consider adding a prefix,
>>     > e.g., rg_, to them to make it less confusing? Thanks.
>>     >
>>     > - cs
>>     > - p
>>     > - ...
>>
>>     _______________________________________________
>>     ragel-users mailing list
>>     ragel-users at colm.net <mailto:ragel-users at colm.net>
>>     http://www.colm.net/cgi-bin/mailman/listinfo/ragel-users
>>
>> -- 
>> Regards,
>> Peng
>>
>> _______________________________________________
>> ragel-users mailing list
>> ragel-users at colm.net  <mailto:ragel-users at colm.net>
>> http://www.colm.net/cgi-bin/mailman/listinfo/ragel-users
> 
> _______________________________________________
> ragel-users mailing list
> ragel-users at colm.net
> http://www.colm.net/cgi-bin/mailman/listinfo/ragel-users
> 

-- 
Dr Mark OLESEN
Principal Engineer, ESI-OpenCFD
Engineering System International GmbH | Einsteinring 24 | 85609 Munich
Mob. +49 171 9710 149
www.openfoam.com | www.esi-group.com | mark.olesen at esi-group.com


More information about the ragel-users mailing list