// // Grammatica semplificata di Cognos QDesign // Scritta da Alessandro Polverini // polverini@nibbles.it // Package it.nibbles.p2j.compiler2; Helpers a = ; b = ; c = ; d = ; e = ; f = ; g = ; h = ; i = ; j = ; k = ; l = ; m = ; n = ; o = ; p = ; q = ; r = ; s = ; t = ; u = ; v = ; w = ; x = ; y = ; z = ; allchars = ; tab = ; cr = ; lf = ; noneolchar = ; blanks = ; h_eol = ; comment = ; digit = ; nonzerodigit = ; lowercase = ; uppercase = ; nondigit = ; nondigit_with_dash = ; s_char1 = ; s_char2 = ; States normal, file, field, proc ; Tokens b = ; c = ; e = ; f = ; s = ; plus = ; minus = ; div = ; mod = ; exp = ; colon = ; product =; comma = ; comma_on = ; comma_noton = ; hash = ; l_par = ; r_par = ; l_square_bracket = ; r_square_bracket = ; {normal, field, file} gt = ; {normal, field, file} ge = ; {normal, field, file} lt = ; {normal, field, file} le = ; {normal, field, file} ne = ; {normal, field, file} eq = ; accessok = ; newrecord = ; deletedrecord = ; alteredrecord = ; changemode = ; correctmode = ; entrymode = ; findmode = ; selectmode = ; exists = ; occurrence = ; promptok = ; promptok_for = ; absolute = ; ascii = ; ceiling = ; center = ; f_characters = ; dateextract = ; date = ; days = ; decrypt = ; deletesystemval = ; downshift = ; encrypt = ; first = ; floor = ; getsystemval = ; index = ; lastday = ; lj = ; lower = ; matchpattern = ; nconvert = ; oldvalue = ; random = ; rj = ; round = ; setsystemval = ; size = ; substring = ; sum = ; truncate = ; upper = ; upshift = ; validpattern = ; zerofill = ; accept = ; access = ; action = ; activities = ; alias = ; align = ; all = ; allowed = ; and = ; append = ; ascending = ; audible = ; auto = ; backout = ; backwards = ; background = ; balance = ; begin = ; black = ; blinking = ; block = ; blue = ; break = ; build = ; bwz = ; bytes = ; cache = ; calling = ; cancel = ; caption = ; centered = ; change = ; character = ; close = ; cluster = ; command = ; commit = ; compile = ; constant = ; constraints = ; continue = ; costant = ; count = ; cursor = ; cyan = ; database = ; deferred = ; define = ; deleted = ; descending = ; description = ; designer = ; detail = ; dictionary = ; disable = ; display = ; displayed = ; displaying = ; double = ; draw = ; dual = ; duplicate = ; dynamiclist = ; each = ; edit = ; else = ; entry = ; equals = ; error = ; errors = ; excluded = ; exclusive = ; exit = ; external = ; files = ; fill = ; final = ; find = ; fixed = ; float = ; focus = ; for = ; force = ; form = ; format = ; from = ; full = ; generate = ; generic = ; get = ; green = ; group = ; halftone = ; help = ; hidden = ; hilite = ; if = ; include = ; included = ; information = ; inherited = ; initial = ; initialize = ; input = ; integer = ; internal = ; into = ; inverse = ; item = ; keep = ; key = ; label = ; layout = ; leading = ; let = ; library = ; linedrawing = ; line = ; list = ; local = ; lock = ; lookup = ; magenta = ; mark = ; master = ; memolog = ; menu = ; menuitem = ; menumark = ; message = ; missing = ; mode = ; model = ; modify = ; myview = ; need = ; negative = ; nesting = ; new = ; next = ; noaction = ; noallow = ; noappend = ; noautonext = ; nobwz = ; nochange = ; nocommit = ; nocorrect = ; nodata = ; nodelete = ; nodetail = ; noecho = ; noentry = ; noforce = ; noform = ; nogeneric = ; noid = ; noitems = ; nolabel = ; nolist = ; nomark = ; nomenukey = ; nomenukeys = ; nomode = ; nonullseparator = ; noprint = ; noselect = ; noshift = ; not = ; notdeleted = ; noton = ; nouse = ; noverify = ; now = ; nowait = ; nowarn = ; nowarnings = ; nowraparound = ; null = ; nullseparator = ; occurs = ; off = ; on = ; only = ; open = ; optimistic = ; optional = ; orderby = ; ordered = ; output = ; packed = ; panel = ; passing = ; path = ; pattern = ; perform = ; picture = ; popup = ; positive = ; postcommands = ; postfind = ; postpath = ; postscroll = ; postupdate = ; precommands = ; predisplay = ; preentry = ; prescroll = ; preupdate = ; primary = ; print = ; procedures = ; process = ; prompt = ; protected = ; push = ; put = ; qshow = ; query = ; quit = ; read = ; receiving = ; record = ; recoverable = ; red = ; reference = ; refresh = ; request = ; required = ; reset = ; response = ; retrieving = ; return = ; returning = ; reverse = ; revise = ; rollback = ; run = ; same = ; save = ; scale = ; screen = ; secondary = ; select = ; selectbox = ; separator = ; sequenced = ; sequential = ; set = ; severe = ; share = ; shared = ; show = ; sign = ; signed = ; significance = ; silent = ; skip = ; slave = ; start = ; startup = ; stay = ; stoplog = ; stopscreen = ; subscreen = ; summary = ; target = ; temporary = ; terminate = ; then = ; thick = ; thin = ; thread = ; times = ; title = ; trailing = ; transaction = ; transfer = ; underline = ; unique = ; unlock = ; unsigned = ; update = ; use = ; users = ; using = ; values = ; varchar = ; vertical = ; via = ; viaindex = ; wait = ; warning = ; warnings = ; when = ; while = ; white = ; width = ; window = ; with = ; wraparound = ; write = ; yellow = ; zoned = ; detail_find = ; detail_postfind = ; detail_delete = ; {normal -> field} field = ; {normal -> file} file = ; {normal -> proc} procedure = ; {normal -> proc} do = ; {normal, field, file} at = ; {normal} go = ; {normal} verify = ; {normal, field, file} f_mod = ; {normal, field, file} id = ; {normal, field, file} in = ; {normal, field, file} end = ; {normal, field, file} or = ; of = ; {normal, field, file} to = ; {normal, field, file} numeric = ; {normal, field, file} delete = ; {normal, field, file} clear = ; {normal, field, file} default = ; {file} level = ; {field} data = ; ignorable = ; {normal, file -> normal, field -> normal, proc -> normal} newline = ; one_string = ; dec_num = ; number = ; ident = ; Ignored Tokens ignorable; Productions program = T.newline? everything*; everything = {statement} statement | {verb} verb ; statement = statements T.newline ; verb = {one} verbs T.newline | {block} begin_end T.newline | {if} P.if ; verb_without_if = {one} verbs T.newline | {block} begin_end T.newline ; statements = {access} T.access access_options* | {align} T.align align_group* | {build} T.build build_options* | {cluster} T.cluster cluster_opt* | {define} T.define ident temp_type? when_positive? define_assign? | {description} T.description T.of? desc_type string_list | {draw} T.draw draw_type? draw_par | {field} T.field variable field_opts* | {file} T.file ident in_ident? file_options* | {hilite} T.hilite hilite_object hilite_opt* | {item} T.item variable item_options* | {procedure} T.procedure P.procedure_opt | {screen} T.screen ident screen_options* | {select} T.select T.if? condition | {set} T.set set_options* | {skip} T.skip skip_options? | {subscreen} T.subscreen ident subscreen_options* | {title} T.title string title_par* | {temporary} T.temporary ident temp_type? temp_options* | {transaction} T.transaction T.query T.inherited? trans_opt* ; verbs = {accept} T.accept variable | {block_transfer} T.block T.transfer T.sequenced? T.newline begin_end | {break} T.break | {close} T.close ident | {commit} T.commit T.transaction? ident? | {delete} T.delete ident | {display} T.display variable | {do_internal} T.do internal? ident | {do_external} T.do external ident l_par ident_list r_par | {edit} T.edit variable | {for} T.for T.missing? for_opt* expression T.newline begin_end | {get} T.get ident get_options* | {let} T.let let_var assignment | {lock} T.lock ident lock_opt? lock_type? | {null} T.null | {perform} T.perform T.append | {prompt} T.prompt ident in_ident? T.required? | {push} T.push push_par | {put} T.put put_modifier? ident put_opt_at? reset? | {request} T.request variable | {rollback} T.rollback T.update | {refresh} P.refresh | {return} T.return | {run_command} T.run T.command run_command_name run_command_opts* | {run_screen} T.run T.screen? T.item? ident run_screen_opts* | {run_thread} T.run T.thread T.item? ident T.mode run_screen_mode | {unlock} T.unlock ident | {while} T.while condition T.newline begin_end | {while_retrieving} P.while_retrieving | {messages} messages T.message? T.equals? expression info_opts? ; // TODO: Vedere se è possibile inserire le espressioni di tipo stringa messages = {error} T.error | {severe} T.severe | {warning} T.warning | {information} T.information ; if = T.if condition [i1]:T.newline T.then [i2]:T.newline* verb_without_if opt_else? ; opt_else = T.else T.newline* verb ; in_ident = T.in ident ; begin_end = T.begin T.newline verb* T.end ; info_opts = T.now T.response? ; let_var = {var} P.variable P.substring? | {path} T.path ; push_par = {proc} proc_name | {return} T.return | {update_stay} T.update T.stay | {designer} T.designer P.designer_name ; title_par = {at} T.at [row]:number? T.comma [column]:T.number | {centered} T.centered ; draw_par = {one} [n1]:number T.comma [n2]:number | {normal} T.from? [r1]:number [c1]:draw_col? T.to? [r2]:number [c2]:draw_col? | {columns} T.from? [i1]:T.comma [c1]:T.number T.to? [i2]:T.comma [c2]:T.number ; draw_col = T.comma T.number ; lock_opt = {file} T.file | {record} T.record ; trans_opt = {nocommit} nocommit | {commiton} commit on update | {read} read | {write} write ; lock_type = {exclusive} exclusive | {protected} protected | {shared} shared ; skip_options = {n} number | {to_line} T.to T.line? number | {to_group} T.to T.group? ident ; build_options = {list} list | {detail} detail ; set_options = {nesting} T.nesting number | {verify} T.verify | {noverify} T.noverify | {default} T.default | {delete} T.delete | {summary} T.summary ; put_modifier = {delete} deleted | {new} new | {notdeleted} notdeleted ; put_opt_at = at ident ; for_opt = {each} each | {displayed} displayed | {item} item | {file} file ; draw_type = {thin} T.thin | {thick} T.thick | {double} T.double ; cluster_opt = {at} T.at [l]:number? T.comma [c]:number | {block} T.block T.each? T.all? | {for} T.for [l]:number T.comma [r]:number | {occurs} T.occurs number | {vertical} T.vertical | {occurs_with} T.occurs T.with variable ; align_group = T.l_par number? align_part2? T.r_par ; align_part2 = T.comma number? align_part3? ; align_part3 = T.comma number? ; procedure_opt = {designer} T.designer designer_name designer_opt* T.newline proc_body | {internal} T.internal? proc_name T.newline proc_body | {field} proc_field_name variable T.newline proc_body ; proc_body = {block} begin_end | {null} T.null | {disabled} T.disable ; proc_field_name = {input} T.input | {output} T.output | {process} T.process | {edit} T.edit ; designer_name = {num} T.number | {help} T.help | {of} T.of | {ident} ident ; designer_opt = {precommands} T.precommands proc_name T.stay? | {nodata} T.nodata | {help} T.help string ; proc_name = {append} T.append | {backout} T.backout | {delete} T.delete | {det_delete} T.detail_delete | {det_find} T.detail_find | {det_postfind}T.detail_postfind | {entry} T.entry | {exit} T.exit | {find} T.find | {initialize} T.initialize | {modify} T.modify | {postfind} T.postfind | {postpath} T.postpath | {path} T.path | {preentry} T.preentry | {preupdate} T.preupdate | {postupdate} T.postupdate | {select} T.select | {update} T.update | {internal} ident ; while_retrieving = T.while T.retrieving ident while_retrieving_opts* T.newline begin_end ; while_retrieving_opts = {backwards} T.backwards | {orderby} T.orderby sorted_ident_list | {sequential} T.sequential | {using} T.using exp_list | {viaindex} T.viaindex ident | {via} T.via ident_list order_type? ; run_command_name = {item} T.item? variable | {string} T.one_string ; run_command_opts = {nowarn} T.nowarn | {response} T.response | {refresh} T.refresh T.all? T.screen? | {clear} P.clear | {on_error} P.on_error ; run_screen_opts = {clear} P.clear | {refresh} P.refresh | {mode} T.mode run_screen_mode | {on_error} P.on_error | {passing} T.passing ident_list ; on_error = T.on T.error run_screen_err_action ; run_screen_mode = {e} e | {f} f | {s} s | {null} null | {same} same ; run_screen_err_action = {continue} continue | {terminate} terminate ; clear = T.clear clear_refresh_opt ; refresh = T.refresh clear_refresh_opt ; clear_refresh_opt = {all} all | {screen} screen | {line} line number to_opt? ; to_opt = to number ; subscreen_options = {label} T.label T.one_string | {passing} T.passing ident_list ; screen_options = {action} T.action screen_label_opt? at_row_col? | {noaction} T.noaction | {activities} T.activities activity activity_list_tail* | {for} T.for number T.line? | {form} T.form ident? | {from} T.from [n1]:number? [c1]:comma [n2]:number to [n3]:number? [c2]:comma [n4]:number | {menu} T.menu | {message} T.message T.on? T.line? number | {mode} T.mode screen_label_opt? at_row_col? | {nomode} T.nomode | {on} T.on T.line? number | {panel} T.panel | {slave} T.slave | {stopscreen} T.stopscreen | {receiving} T.receiving ident_list | {transaction} T.transaction T.model T.optimistic | {window} window on? line? number | {commit_type} screen_commit_type screen_continue_on? ; activity = {entry} T.entry | {find} T.find | {change} T.change | {delete} T.delete ; activity_list_tail = T.comma P.activity ; screen_commit_type = {commit} commit on automatic_commit_point | {nocommit} nocommit ; screen_continue_on = continue on automatic_commit_point ; screen_label_opt = T.label string ; at_row_col = T.at [n1]:T.number? T.comma [n2]:T.number ; automatic_commit_point = {mode} T.mode | {update} T.update | {exit} T.exit ; desc_type = {screen} screen | {field} field? variable ; temp_type = var_type var_size? var_sign ; var_sign = signed? unsigned? var_sign_size? ; var_sign_size = size number bytes? ; temp_options = {when_positive} when_positive | {sum} T.sum T.into ident | {initial} T.initial expression | {occurs} T.occurs temp_occurs_params | {reset} T.reset temp_reset_opt? ; temp_occurs_params = {num} number times? | {with} with item? file? ident ; temp_reset_opt = at temp_reset_mode ; temp_reset_mode = {mode} mode | {startup} startup ; item_options = {final} final define_exp | {initial} initial define_exp fixed? ; access_options = {orderby} T.orderby sorted_ident_list | {nogeneric} T.nogeneric | {optional} T.optional | {sequential} T.sequential | {unique} T.unique | {request} T.request var_list | {using} T.using exp_list | {via} T.via ident_list order_type? | {viaindex} T.viaindex ident ; define_assign = T.equals define_exp ; define_exp = expression define_if? ; define_if = T.if condition define_else? ; define_else = T.else define_exp? ; when_positive = T.when T.positive ; get_options = {generic} T.generic | // TODO: vedere se toglierlo dai pochi sorgenti che lo usano {nogeneric} T.nogeneric | // TODO: vedere se toglierlo dai pochi sorgenti che lo usano {orderby} T.orderby sorted_ident_list | {backwards} T.backwards | {optional} T.optional | {sequantial} T.sequential | {unique} T.unique | {using} T.using exp_list | {viaindex} T.viaindex ident | {via} T.via ident_list order_type? ; field_opts = {bwz} T.bwz | {upshift} T.upshift | {nobwz} T.nobwz | {char} T.character | {date} T.date | {num} T.numeric | {nolabel} T.nolabel | {noshift} T.noshift | {noid} T.noid | {fixed} T.fixed | {help} T.help string | {format} T.format ident | {hidden} T.hidden | {nochange} T.nochange | {nocorrect} T.nocorrect | {noecho} T.noecho | {noentry} T.noentry | {noselect} T.noselect | {pattern} T.pattern string | {picture} T.picture string | {predisplay} T.predisplay | {refresh} T.refresh | {required} T.required | {silent} T.silent | {leading} T.leading T.sign? string | {trailing} T.trailing T.sign? string | {size} T.size number | {separator} T.separator T.one_string | {display} T.display on_entry_or_find? | {label} T.label string? at_row_col? | {input} T.input T.scale? expression | {output} T.output T.scale? expression | {data} T.data T.at [l]:T.number? T.comma [c]:T.number | {values} T.values values_arg | {dynamiclist} T.dynamiclist variable dynamiclist_opt* | {significance1} T.significance number | {significance2} T.sign number | // TODO: Unificare nell'AST? {selectbox} T.selectbox selbox_opt_from? selbox_opt_to? selbox_opt_on?| {hilite} T.hilite T.display hilite_opt* | // field_hilite_if? | {lookup} T.lookup lookup_pars | {for} T.for [n1]:T.number? T.comma [n2]:T.number | {if} T.if condition field_hilite_opt_else? | {id_same} T.id T.same | {id_next} T.id T.next | {id_n} T.id T.number ; dynamiclist_opt = {while} while_retrieving_opts | {onfocus} T.on dynamic_on | {duisplaying} T.displaying variable ; dynamic_on = {startup} T.startup | {focus} T.focus ; selbox_opt_from = T.from [n1]:T.number? T.comma [n2]:T.number ; selbox_opt_to = T.to [n1]:T.number? T.comma [n2]:T.number ; selbox_opt_on = T.on selbox_on_mode ; selbox_on_mode = {request} T.request | {edit} T.edit | {input} T.input ; on_entry_or_find = {on_entry} T.on T.entry | {find} T.find ; field_hilite_if = T.if condition field_hilite_opt_else? ; field_hilite_opt_else = T.else hilite_opt* ; hilite_object = {background} T.background | {display} T.display | {edit} T.edit | {error} T.error | {help} T.help | {id} T.id | {information} T.information | {input} T.input | {label} T.label | {linedrawing} T.linedrawing | {menu} T.menu | {menumark} T.menumark | {message} T.message | {mode} T.mode | {request} T.request | {selectbox} T.selectbox | {severe} T.severe | {title} T.title | {warning} T.warning ; hilite_opt = {ident} ident_list | {color} P.hilite_color | {audible} T.audible | {blinking} T.blinking | {default} T.default | {halftone} T.halftone | {inverse} T.inverse | {off} T.off | {underline} T.underline ; hilite_color = P.color hilite_color_opt? ; hilite_color_opt= T.on P.color ; file_options = {delete} T.delete | {designer} T.designer | {detail} T.detail | {master} T.master | {primary} T.primary | {reference} T.reference | {secondary} T.secondary | {alias} T.alias ident | {close} T.close | {noappend} T.noappend | {nodelete} T.nodelete | {noitems} T.noitems | {open} T.open open_type? open_params T.exclusive? T.share? | {need} T.need number_all | {occurs} T.occurs occurs_params | {transaction} T.transaction T.ident ; occurs_params = {number} T.number T.times? | {with} T.with T.item? T.file? T.ident ; number_all = {number} T.number | {all} T.all ; open_type = {number} T.number | {eachlevel} T.each T.level ; open_params = {append} T.append | {clear} T.clear | {read} T.read | {update} T.update | {write} T.write ; // // Parti comuni a molti comandi // var_size = product number ; assignment = equals expression ; var_list = variable var_list_tail* ; var_list_tail = comma variable ; ident_list = ident ident_list_tail* ; ident_list_tail = comma ident ; sorted_ident_list = ident sort_type? sorted_ident_list_tail* ; sorted_ident_list_tail = comma ident sort_type? ; string_list = string string_list_tail* ; string_list_tail = comma string ; exp_list = expression exp_list_tail* ; exp_list_tail = comma expression ; when_pos_or_neg = when pos_or_neg ; pos_or_neg = {positive} positive | {negative} negative ; incl_or_excl = {included} included | {excluded} excluded ; order_type = ordered sort_type? ; sort_type = {asc} ascending | {desc} descending ; var_type = {zoned} T.zoned | {varchar} T.varchar | {char} T.character | {date} T.date | {numeric} T.numeric | {int} T.integer | {packed} T.packed ; message_x = T.message message_opt ; message_opt = {string} string | {ident} T.equals expression ; string = one_string+ ; lookup_pars = on_or_noton lookup_pars2 lookup_pars_tail* ; lookup_pars2 = ident while_retrieving_opts* T.optional? message_x? ; lookup_pars_tail = {on} T.comma_on lookup_pars2 | {noton} T.comma_noton lookup_pars2 ; on_or_noton = {on} T.on | {not} T.not | {noton} T.noton ; // // Espressioni // condition = {bfactor} andfactor | {or} condition or andfactor ; andfactor = {bfactor} bfactor | {and} andfactor and bfactor ; bfactor = {factor} expression | {relop} [e1]:expression relop [e2]:expression ; expression = {factor} factor | {plus} expression plus factor | {minus} expression minus factor ; factor = {term} simple_expression | {mul} factor product simple_expression | {div} factor div simple_expression | {exp} factor exp simple_expression ; relop = {equals} T.equals | {eq} T.eq | {ne} T.ne | {lt} T.lt | {le} T.le | {ge} T.ge | {gt} T.gt ; unop = {minus} T.minus | {not} T.not ; simple_expression = unop? s_expr P.substring?; substring = l_square_bracket [e1]:expression colon [e2]:expression r_square_bracket; numeric_value = {integer} number | {float} dec_num ; // nibTODO: Visto ke le funzioni sono note a priori, prevedere il controllo del numero dei parametri // gia' nella grammatica per quelle per cui e' possibile s_expr = {integer} T.number | {float} T.dec_num | {string} P.string | {accessok} T.accessok | {changemode} T.changemode | {correctmode} T.correctmode | {entrymode} T.entrymode | {findmode} T.findmode | {selectmode} T.selectmode | {brackets} T.l_par P.condition T.r_par | {func_call} P.function T.l_par exp_list T.r_par | {promptok} T.promptok | {promptokfor} T.promptok_for variable | {newrecord} T.newrecord of_record_optional? | {deletedrecord} T.deletedrecord of_record_optional? | {alteredrecord} T.alteredrecord of_record_optional? | {occurrence} T.occurrence of_record_optional? | {path} T.path | {variable} P.variable ; variable = ident of_record_optional? ; of_record_optional = T.of ident ; // TODO: Unificarle nell'AST function = {absolute} absolute | {ascii} ascii | {ceiling} ceiling | {center} center | {characters} f_characters | {dateextract} dateextract | {days} days | {decrypt} decrypt | {date} date | {deletesysval} deletesystemval | {downshift} downshift | {encrypt} encrypt | {first} first | {floor} floor | {getsystemval} getsystemval | {index} index | {lastday} lastday | {lj} lj | {lower} lower | {matchpattern} matchpattern | {mod} f_mod | {nconvert} nconvert | {oldvalue} oldvalue | {random} random | {rj} rj | {round} round | {setsystemval} setsystemval | {size} size | {substring} T.substring | {sum} sum | {truncate} truncate | {upper} upper | {upshift} upshift | {validpattern} validpattern | {zerofill} zerofill ; color = {red} red | {black} black | {white} white | {blue} blue | {cyan} cyan | {green} green | {magenta} magenta | {yellow} yellow ; values_arg = values_arg111 values_arg_tail* ; values_arg_tail = T.comma values_arg111 ; values_arg_to = T.to num_or_string ; values_arg111 = num_or_string values_arg_to? value_caption? ; value_caption = T.caption T.one_string ; nums_interval_list = nums_interval nums_interval_tail* ; nums_interval_tail = T.comma nums_interval ; nums_interval = [m1]:T.minus? [n1]:numeric_value T.to [m2]:T.minus? [n2]:numeric_value; num_or_string = {integer} minus? number | {float} minus? dec_num | {string} one_string ;