📄 nomparser.jj
字号:
| < NEPTUNIUM: "neptunium" >| < PLUTONIUM: "plutonium" >| < AMERCIUM: "amercium" >| < CURIUM: "curium" >| < BERKELIUM: "berkelium" >| < CALIFORNIUM: "californium" >| < EINSTEINIUM: "einsteinium" >| < FERMIUM: "fermium" >| < MENDELEVIUM: "mendelevium" >| < NOBELIUM: "nobelium" >| < LAWRENCIUM: "lawrencium" >}/** * The general form all chemical names must follow. */void completeChemicalName() :{}{ LOOKAHEAD (2) ( mainChainConstruct() ) | ( prefixConstruct() mainChainConstruct() ) <EOL> }/** * Allows 1 or more prefixes */void prefixConstruct() :{}{ //Dash not needed in the first case prefixType() (<DASH> prefixType())*}void prefixType() :{}{ ( attachLocationSpecified() | AddUnknownFunGroupPos() ) ( subChain() | functionalGroupPrefix() )}/** The substituent part of the prefix */void subChain() :{}{ //Only allow *specified location* substituents delt with in prefixType() chainPrefix() AddHeadToken() <YL>}/** * An attach position has been specified using a * comma seperated list followed by a dash */void attachLocationSpecified() :{}{ //Must be at least one constant, so add that to begin with. <CONSTANT> AddFunGroupPos() ( oneAttachLocation() | twoOrThreeAttachLocations() )}/** * Only one attach location specified, should be followed by a dash. */void oneAttachLocation() :{}{ <DASH>}/** * Two or three attach locations specidied, handle the second and if needed, the third one here. */void twoOrThreeAttachLocations() :{}{ <COMMA> <CONSTANT> AddFunGroupPos() ( (<DASH> <DI>) | (<COMMA> <CONSTANT> AddFunGroupPos() <DASH> <TRI>) )}/** * A list of known tokens denoting a chain's length. */void chainPrefix() :{}{ specialCase() | allBaseNumbers() [tensWithUnits() | tensNoUnits()]}/** Deal with special cases where the rules don't apply. */void specialCase() :{}{ < METH > {currentNumber = 1;}| < ETH > {currentNumber = 2;}| < PROP > {currentNumber = 3;}| < BUT > {currentNumber = 4;}| < DEC > {currentNumber = 10;}| < UNDEC > {currentNumber = 11;}| < EICOS > {currentNumber = 20;}| < HENICOS > {currentNumber = 21;}}/** The usual numbers .*/void allBaseNumbers() :{}{ < HEN > {currentNumber = 1;}| < DO > {currentNumber = 2;}| < TRI > {currentNumber = 3;}| < TETR > {currentNumber = 4;}| < PENT > {currentNumber = 5;}| < HEX > {currentNumber = 6;}| < HEPT > {currentNumber = 7;}| < OCT > {currentNumber = 8;}| < NON > {currentNumber = 9;}}/** Deal with fragments refering to the positioning of the base numbers (denoting their magnitude) */void tensNoUnits() :{}{ <DEC> { currentNumber += 10; }| <COS> { currentNumber += 20; }| <CONT> { currentNumber *= 10; }}/** * Deals with numbers above 30 where the base numbers set appear twice. * For example, in the tens and the units. */void tensWithUnits() :{ int tempBackup;}{ { tempBackup = currentNumber; } allBaseNumbers() <CONT> { currentNumber *= 10; currentNumber += tempBackup; }}/** The functional group part of the prefix */void functionalGroupPrefix() :{}{ prefixFunctionalGroups() AddFunGroup()}/** * Main chains are compulsary and consist of an optional "cyclo", a length prefix and * a posfix denoting functional groups. */void mainChainConstruct() :{}{ [cycle()] mainChainPrefix()( <YL> AddUnknownFunGroupPos() MakeMainChainIntoSubstituent() ( prioritySubstituents() | mainChainPrefix() <AN> prioritySubstituentsFunGroups() ) AddUnknownFunGroupPos() AddFunGroup() | bondType() mainChainSuffix() )}/** * Deals with cyclic main chains. */void cycle() :{}{ <CYCLO> SetMainCyclic()}/** * Deal with the main chain's length. */void mainChainPrefix() :{}{ chainPrefix() AddMainChain()}/** * Tokens which affect the bond order of the first bond. */void bondType() :{}{ ( <AN> AddUnknownFunGroupPos() | ( <DASH> attachLocationSpecified() | AddUnknownFunGroupPos() ) ( <EN> | <YN> ) ) AddFunGroup()}/** * Figure out the functional group by the main chain's suffix. */void mainChainSuffix() :{}{ endFunctionalGroups() | connectingFunctionalGroupsConstruct()}/** * Functional groups which occur at the end of the main chain and need * a connecting "an". */void endFunctionalGroups() :{}{( <E>[<NITRILE>]| <AMIDE>| <AMINE>| <OATE>| <ONE>| <OICACID>| <OYLCHLORIDE>| <AL> ) AddUnknownFunGroupPos() AddFunGroup()}/** * The layout of a functional group(s) which can connect anywhere. * No number specified, or a number list specified. */void connectingFunctionalGroupsConstruct() :{}{ ( connectingFunctionalGroupSuffix() AddUnknownFunGroupPos() | <DASH> attachLocationSpecified() connectingFunctionalGroupSuffix() ) AddFunGroup()}/** * Functional groups suffixs for groups which can be connected anywhere * along the main chain. */void connectingFunctionalGroupSuffix() :{}{ <OL>}void prefixFunctionalGroups() :{}{ <CHLORO>| <BROMO>| <IODO>| <FLUORO>| <NITRO>| <OXO>| <PHENYL>| <AMINO>| <HYDROXY>}/** * Things which have sub chains branching off them and the molecule does have a main chain. */void prioritySubstituentsFunGroups() :{}{ <AMINE>| <AMIDE>| <OATE>| <ONE>}/** * Things which have sub chains branching off them but the molecule has no main chain. */void prioritySubstituents () :{}{ groupOneMetals()| groupTwoMetals()| dBlockMetals()| pBlockMetals()| fBlockMetals()}void groupOneMetals() :{}{ <LITHIUM>| <SODIUM>| <POTASSIUM>| <RUBIDIUM>| <CESIUM>| <FRANCIUM>}void groupTwoMetals() :{}{ <BERYLLIUM>| <MAGNESIUM>| <CALCIUM>| <STRONTIUM>| <BARIUM>| <RADIUM>}void dBlockMetals() :{}{ <SCANDIUM>| <YTTRIUM>| <LANTHANUM>| <ACTINIUM>| <TITANIUM>| <ZIRCONIUM>| <HAFNIUM>| <RUTHERFORDIUM>| <VANADIUM>| <NIOBIUM>| <TANTALUM>| <DUBNIUM>| <CHROMIUM>| <MOLYBDENUM>| <TUNGSTEN>| <SEABORGIUM>| <MANGANESE>| <TECHNETIUM>| <RHENIUM>| <BOHRIUM>| <IRON>| <RUTHENIUM>| <OSMIUM>| <HASSIUM>| <COBALT>| <RHODIUM>| <IRIDIUM>| <MEITMERIUM>| <NICKEL>| <PALLADIUM>| <PLATINUM>| <COPPER>| <SILVER>| <GOLD>| <ZINC>| <CADMIUM>| <MECURY>}void pBlockMetals() :{}{ <ALUMINIUM>| <GALLIUM>| <INDIUM>| <THALLIUM>| <GERMAINIUM>| <TIN>| <LEAD>| <ARSENIC>| <ANTIMONY>| <BISMUTH>| <SELENIUM>| <TELLURIUM>| <POLONIUM>}void fBlockMetals() :{}{ <CERIUM>| <PRASEODYMIUM>| <NEODYMIUM>| <PROMETHIUM>| <SANARIUM>| <EUROPIUM>| <GADOLINIUM>| <TERBIUM>| <DYSPROSIUM>| <HOLMIUM>| <ERBIUM>| <THULIUM>| <YTTERBIUM>| <LUTETIUM>| <THORIUM>| <PROTACTINIUM>| <URANIUM>| <NEPTUNIUM>| <PLUTONIUM>| <AMERCIUM>| <CURIUM>| <BERKELIUM>| <CALIFORNIUM>| <EINSTEINIUM>| <FERMIUM>| <MENDELEVIUM>| <NOBELIUM>| <LAWRENCIUM>}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -