/** * * dpANSI KIF grammar. * * This is grammar file of: * * Knowledge Interchange Format * draft proposed American National Standard * (dpANS KIF) * NCITS.T2/98-004 * * This file is a KIF parser source file for SableCC * (Sable Compiler Compiler by Etienne Gagnon) which can be * obtained at: http://www.sable.mcgill.ca/sablecc * This file is used to produce OQL parser with related classes * and data structures. * * This is part of the New Zealand Distributed Information Systems (NZDIS) * project, conducted at the University of Otago, Dunedin, New Zealand, * under supervision of Professor Martin Purvis and Doctor Stephen Cranefield. * * * Copyright (C) 1998-2001 Mariusz Nowostawski and others. * All rights reserved. (see doc/LICENSE and doc/AUTHORS) * * Contact: * e-mail: mariusz@rakiura.org * * This grammar lacks only: * - character blocks * apart from that, this is full dpANS KIF grammar * and parser generated by SableCC will be compatibile * with dpANS KIF. * * (Attention! Do not mix dpANS KIF with the older KIF 3.0 * while those two specs differ a little in theirs' grammars.) * * This file is part of the nzdis-kif package. * * * Version 1.1 $Revision: 1.1 $ */ Package nzdis.lang.kif; Helpers tab = 9; cr = 13; lf = 10; eol = cr lf | cr | lf |; white = (' ' | tab | eol)+ ; upper = ['A'..'Z']; lower = ['a'..'z']; digit = ['0'..'9']; alpha = [ [ [['!' + '$'] + ['%' + '&']] + [['*' + '+'] + ['-' + '.']] ] + [ [['/' + '<'] + ['@' + '?']] + [['>' + '='] + ['_' + '~']] ] ]; special = [[[['"' + '#'] + ['(' + ')']] + [[',' + '\'] + ['^' + '`']]] + '''] ; normal = [[upper + lower] + [digit + alpha]] ; word = (normal | '\' [[0 .. 0xffff] - [[10 + 13] + [9 + ' ']]] )+; l_par = '('; r_par = ')'; r_ap = '''; u_arrow = '^'; eq = '='; ineq = '/='; at = '@'; q_mark = '?'; col_eq = ':='; quote = 'qoute'; defobject = 'defobject'; deffunction = 'deffunction'; defrelation = 'defrelation'; deflogical = 'deflogical'; not = 'not'; and = 'and'; or = 'or'; dbl_r_arrow = '=>'; dbl_l_arrow = '<='; arrow_dbl_arrow = '<=>'; if = 'if'; cond = 'cond'; value = 'value'; listof = 'listof'; holds = 'holds'; forall = 'forall'; exists = 'exists'; col_dbl_r_arrow = ':=>'; col_dbl_l_arrow = ':<='; col_r_arrow = ':->'; Tokens line_comment = '/' '/' [[0 .. 0xffff] - [cr + lf]]* eol | ';' [[0 .. 0xffff] - [cr + lf]]* eol ; multiline_comment = '/' '*' [[0 .. 0xffff] - ['*' + '/']]* '*' '/' ; string = '"' ([[0 .. 0xffff] - ['"' + '\']] | '\'[0 .. 0xffff])+ '"'; charref = '#' '\' [0 .. 0xffff]; l_par = l_par; r_par = r_par; r_ap = r_ap; u_arrow = u_arrow; eq = eq; ineq = ineq; at = at; q_mark = q_mark; col_eq = col_eq; quote = quote; defobject = defobject; deffunction = deffunction; defrelation = defrelation; deflogical = deflogical; not = not; and = and; or = or; dbl_r_arrow = dbl_r_arrow; dbl_l_arrow = dbl_l_arrow; arrow_dbl_arrow = arrow_dbl_arrow; col_dbl_r_arrow = col_dbl_r_arrow; col_dbl_l_arrow = col_dbl_l_arrow; col_r_arrow = col_r_arrow; if = if; cond = cond; value = value; listof = listof; holds = holds; forall = forall; exists = exists; t_seqvar = '@' word ; t_indvar = '?' word ; ref_seqvar = ',@' word ; ref_indvar = ',?' word ; word = word; white = white; Ignored Tokens white, line_comment, multiline_comment; Productions base = {knowledge} form*; form = {sentence} sentence | {definition} definition ; sentence = {constant} constant | {equation} equation | {inequality} inequality | {relsent} relsent | {logsent} logsent | {quantsent} quantsent ; definition = {unrestricted} unrestricted | {complete} complete | {partial} partial ; unrestricted = {defobject} l_par defobject constant string? sentence* r_par | {deffunction} l_par deffunction constant string? sentence* r_par | {defrelation} l_par defrelation constant string? sentence* r_par | {deflogical} l_par deflogical constant string? sentence* r_par ; complete = {defobject} l_par defobject constant string? col_eq term r_par | {deffunction} l_par deffunction constant [par1]:l_par indvar* seqvar? [par2]:r_par string? col_eq term r_par | {defrelation} l_par defrelation constant [par1]:l_par indvar* seqvar? [par2]:r_par string? col_eq sentence r_par | {deflogical} l_par deflogical constant string? col_eq sentence r_par ; partial = {defobject_l} l_par defobject constant string? col_r_arrow indvar col_dbl_l_arrow sentence r_par | {defobject_r} l_par defobject constant string? col_r_arrow indvar col_dbl_r_arrow sentence r_par | {deflogical_l} l_par deflogical constant string? col_dbl_l_arrow sentence r_par | {deflogical_r} l_par deflogical constant string? col_dbl_r_arrow sentence r_par | {deffunction_l} l_par deffunction constant [par1]:l_par indvar* seqvar? [par2]:r_par string? col_r_arrow [a]:indvar col_dbl_l_arrow sentence r_par | {deffunction_r} l_par deffunction constant [par1]:l_par indvar* seqvar? [par2]:r_par string? col_r_arrow [a]:indvar col_dbl_r_arrow sentence r_par | {defrelation_l} l_par defrelation constant [par1]:l_par indvar* seqvar? [par2]:r_par string? col_dbl_l_arrow sentence r_par | {defrelation_r} l_par defrelation constant [par1]:l_par indvar* seqvar? [par2]:r_par string? col_dbl_r_arrow sentence r_par ; equation = l_par eq [left]:term [right]:term r_par ; inequality = l_par ineq [left]:term [right]:term r_par ; relsent = {implicit} l_par constant term* seqvar? r_par | {explicit} l_par holds [first]:term [rest]:term* seqvar? r_par; varspec = {single} variable | {list} l_par variable constant r_par ; variable = {indvar} indvar | {seqvar} seqvar ; indvar = t_indvar; seqvar = t_seqvar; funterm = {implicit} l_par constant term* seqvar? r_par | {explicit} l_par value [first]:term [rest]:term* seqvar? r_par; listterm = l_par listof term* seqvar? r_par; quoterm = {par} l_par quote listexpr r_par | {simple1} r_ap listexpr | {simple2} u_arrow listexpr; listexpr = {indvar} indvar | {seqvar} seqvar | {word} word | {defined_symbol} defined | {string} string | {charref} charref | {seqvar_ref} ref_seqvar | {indvar_ref} ref_indvar | {multi} l_par listexpr* r_par ; logterm = {if} l_par if sentence [true]:term [false]:term? r_par | {cond} l_par cond logitem* r_par ; logitem = l_par sentence term r_par; logsent = {negation} l_par not sentence r_par | {conjunction} l_par and sentence* r_par | {disjunction} l_par or sentence* r_par | {implication} l_par dbl_r_arrow [rest]:sentence* [last]:sentence r_par | {reverse_implication} l_par dbl_l_arrow [first]:sentence [rest]:sentence* r_par | {equivalence} l_par arrow_dbl_arrow [first]:sentence [last]:sentence r_par ; quantsent = {universal} l_par forall [par1]:l_par varspec+ [par2]:r_par sentence r_par | {existential} l_par exists [par1]:l_par varspec+ [par2]:r_par sentence r_par ; identifier = {word} word; constant = identifier; term = {indvar} indvar | {constant} constant | {charref} charref | {string} string | {funterm} funterm | {listterm} listterm | {quoterm} quoterm | {logterm} logterm ; defined = {r_ap} r_ap | {u_arrow} u_arrow | {eq} eq | {ineq} ineq | {at} at | {q_mark} q_mark | {col_eq} col_eq | {quote} quote | {defobject} defobject | {deffunction} deffunction | {defrelation} defrelation | {deflogical} deflogical | {not} not | {and} and | {or} or | {dbl_r_arrow} dbl_r_arrow | {dbl_l_arrow} dbl_l_arrow | {arrow_dbl_arrow} arrow_dbl_arrow | {col_dbl_r_arrow} col_dbl_r_arrow | {col_dbl_l_arrow} col_dbl_l_arrow | {col_r_arrow} col_r_arrow | {if} if | {cond} cond | {value} value | {listof} listof | {holds} holds | {forall} forall | {exists} exists ; /* *********** end of file *********** */
This site has been last updated by the web master
on 2007/6/24.