aminePlatform.util.parserGenerator
Class CGIFParserGenerator
java.lang.Object
aminePlatform.util.parserGenerator.ObjectParsing
aminePlatform.util.parserGenerator.CGIFParserGenerator
- All Implemented Interfaces:
- AmineConstants, SynergyTypeConstants
- public class CGIFParserGenerator
- extends ObjectParsing
- implements AmineConstants, SynergyTypeConstants
Title : parserGenerator.CGIFParserGenerator Class
Description : This class is responsible of two tasks :
- parse the CGIF notation of a CG and generate its internal representation,
- generate a CGIF notation of a CG from its internal representation.
The first task, CGIF-To-CG, is done by the method parse() that parses the CGIF
notation of a CG and produces the internal representation of the CG.
The second task, CGIF-From-CG, is done by the method toCGIF() that generates a CGIF
notation from the internal representation of a CG.
The syntax of CGIF notation :
CG ::= {Concept | ConceptualRelation | Comment}*
Concept ::= "[" [Comment] Conc_Type [ParameterModes (generate in EndComment)] [CoReferent]
[":"] [CoReferent] [Designator] [CoReferent] ["="] [Descriptor] [CoReferent] // Coreferent (defining/* | bound/? coreference label/Variable) can be specified before or after. Note also, a set of designator is not enclosed in {}
["$" State (generate in EndComment)] ["&" Point (generate in EndComment)] [EndComment] "]"
ConceptualRelation ::= Relation | Actor
Relation ::= "(" [Comment] Type Argument Argument [EndComment] ")"
Actor ::= "(" [Comment] Type {Argument} "|" {Argument} [EndComment] ")"
Argument ::= Concept | Coreferent | Designator | Descriptor
Comment ::= "/*" {(character-"*") | ["*" (character-"/")]} ["*"] "* /"
EndComment ::= ";" {character - ("]" | ")")}
Copyright : Copyright (c) Adil KABBAJ 2004-2009
Fields inherited from interface aminePlatform.util.AmineConstants |
ANALOGY, B_ASSIGN, B_DSPLY_WT_DELAY, B_DSPLY_WTT_DELAY, B_TRIGGER, B_WTT_DSPLY, BLOCK_BACKWARD_PROPAGATION, BLOCK_FORWARD_PROPAGATION, CANON, CGIF, CGRAPHIC, CHECK_PRECONDITIONS, COMPARE, COMPOSED_GOAL, CONCEPT_TYPE_IDENT, CONTEXT, COVERED_BY, CPLTE_CONTRACT, DEFINITION, EQ_OR_MORE_SPCFQ, EQUAL, EXPAND, FALSE_FOCUS_LIST, FUNCTIONAL, GENERALISE, GENERALIZE, HAVE_AN_INTERSECTION, ID_ADD, ID_DIV, ID_EQ, ID_INF, ID_IS, ID_MESSAGE, ID_MUL, ID_NOT, ID_NULL, ID_OPER_AND, ID_OPER_OR, ID_SUB, ID_SUP, IN_ACTIVATION, IN_MODE, IN_MODE2, INDIVIDUAL, INDIVIDUAL_IDENT, INTEGRATED, IS_CANONIC, KEY_GLOBAL_RULE, LC_ADD, LC_AMINE_BOOLEAN, LC_AMINE_DOUBLE, LC_AMINE_INTEGER, LC_AND, LC_BOOLEAN, LC_CG, LC_CLOSE_BRKT, LC_CLOSE_PARENT, LC_CLOSE_SET, LC_COMMA, LC_COMMA_SEMI, LC_CONCEPT, LC_CONSTRUCTOR, LC_CS, LC_CUT, LC_DIFF, LC_DIV, LC_DOUBLE, LC_DSBL_BKWRD_PRPGTN, LC_DSBL_FRWRD_PRPGTN, LC_EOF, LC_EQ, LC_FOUR_POINTS, LC_IDENTIFIER, LC_IF, LC_INF, LC_INTEGER, LC_INTEROG, LC_IS, LC_JAVA_OBJECT, LC_LEFT_ARROW, LC_LIST, LC_NULL, LC_OPEN_BRKT, LC_OPEN_PARENT, LC_OPEN_SET, LC_OPER_AND, LC_OPER_OR, LC_POINT, LC_RELATION, LC_RGHT_ARROW, LC_SEMI_COMMA, LC_SET, LC_STAR, LC_STATE, LC_STRING, LC_SUB, LC_SUP, LC_TERM, LC_TWO_POINTS, LC_VAR_LIST_CONSTRUCTOR, LC_VARIABLE, LF, MAXIMAL_JOIN, MORE_GENERAL, MORE_SPECIFIC, NOTHING_TO_INTEGRATE, OPERS_WITH_RSLT, OUT_MODE, OUT_MODE2, PARTIAL_CONTRACT, PARTIAL_SUBSUME, PRJCT_OPERS, PROJECT, READ, READ_SENTENCE, RELATION_TYPE_IDENT, S_AND, S_BOOLEAN, S_CG, S_CLOSE_BRKT, S_CLOSE_PARENT, S_CLOSE_SET, S_COMMA, S_CONCEPT, S_CONSTRUCTOR, S_CUT, S_DIFF, S_DOUBLE, S_EOF, S_EQUAL, S_EXPAND, S_FALSE, S_FOUR_POINTS, S_GENERALISE, S_GENERALIZE, S_IDENTIFIER, S_IF, S_INTEGER, S_INTEROG, S_IS, S_IS_CANONIC, S_LEFT_ARROW, S_LIST, S_MAXIMAL_JOIN, S_OPEN_BRKT, S_OPEN_PARENT, S_OPEN_SET, S_POINT, S_RGHT_ARROW, S_SEMI_COMMA, S_SOURCE, S_SPECIALIZE, S_STATE, S_STRING, S_SUBSUME, S_SUBSUME_WITH_RESULT, S_SUPER, S_TARGET, S_TERM, S_THIS, S_TRUE, S_TWO_POINTS, S_UNIFY, S_VARIABLE, SITUATION, SPECIALIZE, STEADY, SUBSUME, SUBSUME_WITH_RSLT, TRIGGER, UNCOMPARABLE, UNIFY, VAR_SUPER, WAIT_ASSIGNMENT, WAIT_END_OF_ASSIGNMENT, WAIT_PRECONDITIONS, WAIT_VALUE |
Fields inherited from interface aminePlatform.kernel.SynergyTypeConstants |
ADD_IDENT, ADD_TYPE, AND_IDENT, AND_TYPE, ARITHMETIC_IDENT, ARITHMETIC_OPERS, ARITHMETIC_TYPE, ASSIGN_IDENT, ASSIGN_TYPE, BOOLEAN_IDENT, BOOLEAN_OPER_IDENT, BOOLEAN_OPER_TYPE, BOOLEAN_OPERS, BOOLEAN_TYPE, CG_IDENT, CG_TYPE, DATA_IDENT, DATA_TREATMENT, DATA_TYPE, DIF_IDENT, DIF_TYPE, DIV_IDENT, DIV_TYPE, DIVD_IDENT, EQUAL_IDENT, EQUAL_TYPE, FUNC_TYPE, FUNCTION_IDENT, GRD_IDENT, GRD_RELTYPE, GRD1_IDENT, GRD1_RELTYPE, GRTEQ_IDENT, GRTTHAN_IDENT, IN_IDENT, IN_OUT_IDENT, IN_OUT_OPERS, IN_OUT_TYPE, IN_RELTYPE, INF_IDENT, INF_TYPE, INFEQ_IDENT, INFEQ_TYPE, INT_IDENT, INT_TYPE, LAZY_IDENT, LAZY_TYPE, LESSEQ_IDENT, LESSTHAN_IDENT, LIST_IDENT, LIST_TYPE, MINUS_IDENT, MUL_IDENT, MUL_TYPE, MULT_IDENT, NEXT_IDENT, NEXT_RELTYPE, NOT_IDENT, NOT_TYPE, NOTEQ_IDENT, NOTEQ_TYPE, NOTEQL_IDENT, NUMBER_DATA, NUMBER_IDENT, NUMBER_TYPE, OBJECT_IDENT, OBJECT_TYPE, OPER_TYPE, OPERATION_IDENT, OR_IDENT, OR_TYPE, OUT_IDENT, OUT_RELTYPE, PLUS_IDENT, PRIMITIVE_FUNCTIONS, PROC_TYPE, PROCEDURE_IDENT, PROCESS_IDENT, PROCS_TYPE, READ_IDENT, READ_TYPE, REAL_IDENT, REAL_TYPE, RELATIONAL_IDENT, RELATIONAL_OPERS, RELATIONAL_TYPE, RELATIONS, SQRT_IDENT, SQRT_TYPE, STRING_IDENT, STRING_TYPE, SUB_IDENT, SUB_TYPE, SUP_IDENT, SUP_TYPE, SUPEQ_IDENT, SUPEQ_TYPE, SYN_REL_RELTYPE, SYN_TYP_RELTYPE, SYNERGY_DATA, SYNERGY_IDENTIFIERS, SYNERGY_OPERATIONS, SYNERGY_REL_IDENT, SYNERGY_TREATMENT, SYNERGY_TYPE_IDENT, TREATMENT_IDENT, TREATMENT_TYPE, TYPE_ARITHMETIC_OPERS, TYPE_BOOLEAN_OPERS, TYPE_IN_OUT_OPERS, TYPE_PRIMITIVE_FUNCTIONS, TYPE_RELATIONAL_OPERS, WRITE_IDENT, WRITE_TYPE |
Method Summary |
CG |
parse()
This method parses the CGIF formulation of a CG and produces its corresponding
internal representation (Java Object) if this step is intended (this is determined
by the attribute generateCode : if true, the internal representation is produced,
if false only the parsing is done).
|
CG |
parse(java.lang.String strgCG)
Parse a CGIF form of a CG to produce the internal representation of the CG.
|
CG |
parse(TextTokenizer textTokenizer)
This method is similar to parse(String strgCG) except that its argument
is a TextTokenizer that is already created for the treatment of strgCG;
the textual formulation of a CG. |
CG |
parse(TextTokenizer textTokenizer,
AmineList newTypes)
|
protected CG |
parseCG()
Redefine the method parseCG() of the super-class ObjectParsing.
|
java.lang.String |
toCGIF(BindingContext bindContext,
CG cg,
java.lang.Object bindInf,
int indent)
Generate the CGIF formulation from the internal representation of the
specified CG (parameter cg).
|
protected java.lang.String |
toCGIFBis(BindingContext bindContext,
CG cg,
java.lang.Object bindInf,
int indent)
Generation of the CGIF notation for a given CG. |
Methods inherited from class aminePlatform.util.parserGenerator.ObjectParsing |
addPseudoCorefs, addPseudoCorefs, conceptToString, conceptToString, deletePseudoCorefs, deletePseudoCorefs, deletePseudoDesignators, determineCGForm, determineCGForm, finalize, generateDesignator, getBlancsString, getGenerateCode, getLexicon, getTxtTokenizer, getWithDrawingInf, hasSeveralSuper, isAdditiveOper, isDescriptor, isDesignator, isInt, isMultiplicativeOper, isNotOper, isParameterMode, isRelationalOper, parameterMode, parseAmineList, parseAmineList, parseAmineObject, parseAmineObject, parseAmineSet, parseAmineSet, parseCG, parseCG, parseCG, parseCG, parseConcept, parseConcept, parseConcept, parseConcPoint, parseCoref, parseCoreferent, parseCState, parseDescriptor, parseDesignator, parseExpression, parseExprTerm, parseFactor, parseMessage, parseOperName, parsePoint, parsePseudoDesignator, parseRelationType, parseSegmentPoints, parseSentence, parseSimpleExpression, parseState, parseStdSetDesignator, parseTerm, parseTerm, parseTerm, setGenerateCode, setLexicon, setTxtTokenizer, setWithDrawingInf |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CGIFParserGenerator
public CGIFParserGenerator(TextTokenizer txtTokenizer,
Lexicon lexicon)
throws ParsingException
- This constructor calls the corresponding constructor of the super-class
CGIFParserGenerator
public CGIFParserGenerator(Lexicon lexicon)
throws ParsingException
- This constructor calls the corresponding constructor of the super-class
parse
public CG parse(java.lang.String strgCG)
throws ParsingException
- Parse a CGIF form of a CG to produce the internal representation of the CG.
This method corresponds to a call to the method parseCG(strgCG) defined in
the super-class ObjectParsing. See comment on this method for more detail.
- Parameters:
strgCG
- a CGIF formulation of a CG
- Returns:
- the internal representation (Java Object) of the CG.
Returns null if strgCG is null or is empty
- Throws:
throws
- ParsingException if lexico-syntaxic errors occurs during parsing
ParsingException
parse
public CG parse(TextTokenizer textTokenizer)
throws ParsingException
- This method is similar to parse(String strgCG) except that its argument
is a TextTokenizer that is already created for the treatment of strgCG;
the textual formulation of a CG.
- Parameters:
textTokenizer
- a TextTokenizer to treat the parsing of a textual formulation of a CG
- Returns:
- the internal representation (Java Object) of the CG.
Returns null if textTokenizer is null
- Throws:
throws
- ParsingException if lexico-syntaxic errors occurs during parsing
ParsingException
parse
public CG parse(TextTokenizer textTokenizer,
AmineList newTypes)
throws ParsingException
- Throws:
ParsingException
parse
public CG parse()
throws ParsingException
- This method parses the CGIF formulation of a CG and produces its corresponding
internal representation (Java Object) if this step is intended (this is determined
by the attribute generateCode : if true, the internal representation is produced,
if false only the parsing is done).
This method assumes that the CGIF formulation of the CG was already given to
the textTokenizer of the current ObjectParsing and that lexical analysis was
already done.
This method is called in general for a CGIFParserGenerator object that was
created by the constructor : CGIFParserGenerator(TextTokenizer, Lexicon)
A 'stand alone' version of this method, called parseCGIF() is defined in cg.CG class,
it receives the CGIF formulation of a CG as argument and produces its internal
representation.
- Returns:
- the internal representation (Java Object) of the CG if generateCode is true
and null otherwise
- Throws:
ParsingException
- if lexico-syntaxic errors occur during parsing
parseCG
protected CG parseCG()
throws ParsingException
- Redefine the method parseCG() of the super-class ObjectParsing.
The treatment corresponds to a loop that attempts to parse at each iteration
a concept or a relation. The parsing of the concept is similar to the one
performed by the parser of LF and it is defined in ObjectParsing.
The parsing of a relation consists in recognizing the pattern : '(' IdentRel Arg1 Arg2 ')'
where Arg1 and Arg2 are either a concept or a designator (or a pseudo-designator).
- Overrides:
parseCG
in class ObjectParsing
- Returns:
- The internal representation of the CG
- Throws:
ParsingException
- if errors occur during the parsing
toCGIF
public java.lang.String toCGIF(BindingContext bindContext,
CG cg,
java.lang.Object bindInf,
int indent)
throws ToStringException
- Generate the CGIF formulation from the internal representation of the
specified CG (parameter cg).
The method is called in general on a CGIFParserGenerator object that was created
by the constructor CGIFParserGenerator(lexicon).
A 'stand alone' version of this method, called toCGIF(), is defined in cg.CG class.
The general approach in our CGIF formulation is to produce all the concepts
first and then the relations. If a concept is related to only one relation
(input or output relation) then it will be specified directly in the
formulation of the relation.
About the formulation of each concept :
If the concept has no designator and it is related to at least two
relations (input and/or output) then a pseudo-designator is associated to
the concept.
About the formulation of a relation : the two arguments of a relation are
concepts or designators.
- Parameters:
bindContext
- The Binding contextcg
- The CG to textualizebindInf
- The binding information related to the binding context and to cgindent
- an integer that specifies the required indentation
- Returns:
- the CGIF formulation of the CG cg, or null if cg or lexicon is null.
- Throws:
ToStringException
toCGIFBis
protected java.lang.String toCGIFBis(BindingContext bindContext,
CG cg,
java.lang.Object bindInf,
int indent)
throws ToStringException
- Generation of the CGIF notation for a given CG. See the comment on the
method toCGIF().
- Parameters:
bindContext
- The Binding contextcg
- The CG to textualizebindInf
- The binding information related to the binding context and to cgindent
- an integer that specifies the required indentation
- Returns:
- the CGIF formulation of the CG cg, or null if cg or lexicon is null.
- Throws:
ToStringException