This project has moved and is read-only. For the latest updates, please go here.

Optional Parameters Order

Jul 4, 2012 at 4:27 PM

This is first time I'm using Irony, for some database activity. I could able to parse it successfully but want to improve user interface by allowing users to pass optional parameters in any order.

MAP <<table name>>, Target <<table name>> <param1> <param2> <param3> <param4> <param5>  

where param2, param3, param4 and param5 are optional parameters to the map statement. 

Currently I can able to parse if the param values are provided in sequential, ex: param3, followed by param2.

However, I would like users to provide those optional parameters in any order.

Bnf rules for map statement:

map.rule = MAP + Id + comma + TARGET + Id + param1 + param2 + param3 + param4 + param5

param2.rule = Empty | <<some other rules>>

param3.rule = Empty | <<some other rules>>

param4.rule = Empty | <<some other rules>>

param5.rule = Empty | <<some other rules>>

Kindly someone help me.

Jul 4, 2012 at 4:47 PM

Define parameter set as a list (with MakePlus/StarRule method) - look at MiniPython or expression evaluator grammars as an example

Jul 4, 2012 at 5:14 PM
Edited Jul 4, 2012 at 5:15 PM

Thanks for your reply.

I'm currently using MakePlus/StarRule for arguments to a function and other parameters, but in the map rule these parameters are like properties / definitions for each map table in a list of MAP_TABLES.

Param Examples are:


THREADS <number> => a numeric parameter

LIMIT <number> => a numeric parameter


Can you please kindly give me here a good example to put such non-identical params in a MakePlus/MakeStar method

Jul 4, 2012 at 5:33 PM
Edited Jul 4, 2012 at 5:35 PM

I modified my Grammar and I'm getting conflict errors, please help me.


colsmap.Rule = COLMAP + "(" + columnDefList + ")";           

columnDefList.Rule = MakePlusRule(columnDefList, comma, columnDef);           

getval.Rule = GETVAL + "(" + id_simple + "." + id_simple + ")";           

columnDef.Rule = id_simple |                id_simple + equal + id_simple |                id_simple + equal + getval;

tableId.Rule = MakePlusRule(tableId, dot, id_simple);           

mapTableList.Rule = MakeStarRule(mapTableList, eofRule, mapTableDef);           

mapTableDef.Rule = MAP + TABLE + tableId + comma + TARGET + tableId + mapParamsList + colsmap ;

mapParams.Rule = sqlexec | csvcall | limit | threads;           

mapParamsList.Rule = MakePlusRule(mapParamsList, eofRule, mapParams);


Grammar Errors:

Reduce-reduce conflict. State S57, lookaheads: COLMAP ;. Selected reduce on first production in conflict set.

Reduce-reduce conflict. State S76, lookaheads: COLMAP ;. Selected reduce on first production in conflict set.
Jul 4, 2012 at 5:47 PM

you have to post more, it's not enough to see where the conflict is coming from - I need to see the rules that come "before" the COLMAP and thus use it as a lookahead. If possible, post the entire grammar. I'm out for the day (it's 4th here in US), going out for BBQ and fireworks, will look at it when I'm back late tonight or tomorrow. Or maybe somebody around here can help you while I'm away


Jul 4, 2012 at 7:02 PM

Thanks rivantsov for your help I could able to resolve the conflict and also implement unordering of parameters.