blob: 63d07ef65387196f8f826373888f5fa175ad2efc [file] [log] [blame]
/*****************************************************************************
* Copyright (c) 2019 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Xavier Le Pallec (for CEA LIST) xlepallec@lilo.org - Bug 558456
*
*****************************************************************************/
function readAndOrConsume (stream, regexp) {
var result=stream.match(regexp,false);
if (result)
result=stream.match(regexp,true);
return result;
}
//
// TOKENS FOR CLASS DEFINITION
//
function readClassDefStart (stream) {
return readAndOrConsume(stream,/^class/);
}
function readClassName (stream) {
var nameWithoutInvertedCommas=readAndOrConsume(stream,/^[A-Za-z]([A-Za-z0-9])*/);
if (nameWithoutInvertedCommas)
return nameWithoutInvertedCommas;
var nameWithInvertedCommas= readAndOrConsume(stream,/^"[A-Za-z]([A-Za-z0-9 ])*"/);
return nameWithInvertedCommas;
}
//
// TOKENS FOR PROPERTY DEFINITION
//
function readVisibility (stream) {
return readAndOrConsume(stream,/^(\+|-|#|~)/);
}
function readDerived (stream) {
return readAndOrConsume(stream,/^\//);
}
function readPropertyName (stream) {
return readClassName(stream);
}
//
// TOKENS FOR ATTRIBUTE DEFINITION
//
function readAttributeTypeDefStart (stream) {
return readAndOrConsume(stream,/^:/);
}
function readAttributeTypeName (stream) {
var typeNameWithoutInvertedCommas=readAndOrConsume(stream,/^[A-Za-z]([A-Za-z0-9])*(::[A-Za-z]([A-Za-z0-9])*)*/);
if (typeNameWithoutInvertedCommas)
return typeNameWithoutInvertedCommas;
var typeNameWithInvertedCommas= readAndOrConsume(stream,/^""[A-Za-z]([A-Za-z0-9])*(::[A-Za-z]([A-Za-z0-9])*)*"/);
return typeNameWithInvertedCommas;
}
function readAttributeMultiplicity (stream) {
return readAndOrConsume(stream,/^\[(\d)+\.\.(\d+|n|\*)\]/);
}
function readAttributeModifierListStart (stream) {
return readAndOrConsume(stream,/^{/);
}
function readAttributeModifierListSeparator (stream) {
return readAndOrConsume(stream,/^,/);
}
function readAttributeModifierListEnd (stream) {
return readAndOrConsume(stream,/^}/);
}
function readAttributeModifier (stream) {
var basicModifier=readAndOrConsume(stream,/^(readOnly|union|ordered|unordered|unique|nonunique|seq|sequence|id)/);
if (basicModifier)
return basicModifier;
var modifierPointingPropertyWithoutInvertedCommas= readAndOrConsume(stream,/^(redefines|subsets)( )+[A-Za-z]([A-Za-z0-9])*/);
if (modifierPointingPropertyWithoutInvertedCommas)
return modifierPointingPropertyWithoutInvertedCommas;
var modifierPointingPropertyWithInvertedCommas= readAndOrConsume(stream,/^(redefines|subsets)( )*"[A-Za-z]([A-Za-z0-9])*"/);
return modifierPointingPropertyWithInvertedCommas;
}
//
// TOKENS FOR OPERATION DEFINITION
//
function readParameterListStart (stream) {
return readAndOrConsume(stream,/^\(/);
}
function readParameterListSeparator (stream) {
return readAndOrConsume(stream,/^,/);
}
function readParameterListEnd (stream) {
return readAndOrConsume(stream,/^\)/);
}
//
// TOKENS FOR PARAMETER DEFINITION
//
function readParameterDirection (stream) {
return readAndOrConsume(stream,/^(in|out|inout)/);
}
function readParameterName (stream) {
return readClassName (stream);
}
function readParameterTypeDefStart (stream) {
return readAndOrConsume(stream,/^:/);
}
function readParameterTypeName (stream) {
return readAttributeTypeName(stream);
}
function readParameterMultiplicity (stream) {
return readAttributeMultiplicity(stream);
}
//
// sub-case of Parameter Property list
//
function readParameterPropertyListStart (stream) {
return readAndOrConsume(stream,/^{/);
}
function readParameterPropertyListSeparator (stream) {
return readAndOrConsume(stream,/^,/);
}
function readParameterPropertyListEnd (stream) {
return readAndOrConsume(stream,/^}/);
}
function readParameterProperty (stream) {
return readAndOrConsume(stream,/^(ordered|unordered|unique|nonunique|seq|sequence)/);
}
//
// TOKENS FOR OPERATION RETURN TYPE
//
function readReturnTypeDefStart (stream) {
return readAndOrConsume(stream,/^:/);
}
function readReturnTypeName (stream) {
return readAttributeTypeName(stream);
}
function readReturnTypeMultiplicity (stream) {
return readAttributeMultiplicity(stream);
}
//
// sub-case of Operation Property list
//
function readOperationPropertyListStart (stream) {
return readAndOrConsume(stream,/^{/);
}
function readOperationPropertyListSeparator (stream) {
return readAndOrConsume(stream,/^,/);
}
function readOperationPropertyListEnd (stream) {
return readAndOrConsume(stream,/^}/);
}
function readOperationProperty (stream) {
var basicModifier=readAndOrConsume(stream,/^(query|ordered|unordered|unique|nonunique|seq|sequence)/);
if (basicModifier)
return basicModifier;
var modifierPointingPropertyWithoutInvertedCommas= readAndOrConsume(stream,/^redefines( )+[A-Za-z]([A-Za-z0-9])*/);
if (modifierPointingPropertyWithoutInvertedCommas)
return modifierPointingPropertyWithoutInvertedCommas;
var modifierPointingPropertyWithInvertedCommas= readAndOrConsume(stream,/^redefines( )*"[A-Za-z]([A-Za-z0-9])*"/);
return modifierPointingPropertyWithInvertedCommas;
}