Closed mingodad closed 1 year ago
And here is the EBNF
for https://github.com/rose-compiler/rose/blob/weekly/src/3rdPartyLibraries/experimental-jovial-parser/sdf_syntax/Main.sdf
//%%%%%%%%%%
//%% 1.1 THE COMPLETE PROGRAM
//%%%%%%%%%%
//%%Module+ -> CompleteProgram //{cons("CompleteProgram")}
Module ::= CompoolModule //{cons("Module")}
Module ::= ProcedureModule //{cons("Module")}
Module ::= MainProgramModule //{cons("Module")}
//%%%%%%%%%%
//%% 1.2 MODULES
//%%%%%%%%%%
//%% 1.2.1 COMPOOL MODULES
//%%
CompoolModule ::= 'START'
Directive*
'COMPOOL' CompoolName ';'
CompoolDeclarationList
'TERM' //{cons("CompoolModule")}
CompoolName ::= Name //{cons("Name")}
CompoolDeclarationList ::= CompoolDeclaration* //{cons("DeclarationList")} //%% Using DeclarationList traversals
//%% 1.2.2 PROCEDURE MODULES
//%%
ProcedureModule ::= 'START'
//%% Directive* has been moved from the original grammar to DeclarationList
DeclarationList
NonNestedSubroutineList
'TERM' //{cons("ProcedureModule")}
NonNestedSubroutine ::= 'DEF' SubroutineDefinition //{cons("NonNestedSubroutineDEF")}
NonNestedSubroutine ::= SubroutineDefinition //{cons("NonNestedSubroutine")}
DeclarationList ::= Declaration* //{cons("DeclarationList")}
NonNestedSubroutineList ::= NonNestedSubroutine* //{cons("NonNestedSubroutineList")}
//%% 1.2.3 MAIN PROGRAM MODULES
//%%
MainProgramModule ::= 'START'
//%% Directive* has been moved from the original grammar to DeclarationList
DeclarationList
'PROGRAM'
ProgramName ';'
ProgramBody
NonNestedSubroutineList
'TERM' //{cons("MainProgramModule")}
ProgramName ::= Name //{cons("Name")}
ProgramBody ::= Statement //{cons("ProgramSimpleBody")}
ProgramBody ::= 'BEGIN'
//%% Directive* has been moved from the original grammar to DeclarationList
DeclarationList
Statement+
SubroutineDefinition*
LabelList
'END' //{cons("ProgramBody"), prefer}
//%% 1.4 IMPLEMENTATION PARAMETERS
//%%
IntegerMachineParameter ::= 'BITSINBYTE' //{cons("BITSINBYTE")}
IntegerMachineParameter ::= 'BITSINWORD' //{cons("BITSINWORD")}
IntegerMachineParameter ::= 'LOCSINWORD' //{cons("LOCSINWORD")}
IntegerMachineParameter ::= 'BYTEPOS' '('
CompileTimeNumericFormula
')' //{cons("BYTEPOS")} //%% cons used to be "BitsInWord"
IntegerMachineParameter ::= 'BYTESINWORD' //{cons("BYTESINWORD")}
IntegerMachineParameter ::= 'BITSINPOINTER' //{cons("BITSINPOINTER")}
IntegerMachineParameter ::= 'INTPRECISION' //{cons("INTPRECISION")}
IntegerMachineParameter ::= 'FLOATPRECISION' //{cons("FLOATPRECISION")}
IntegerMachineParameter ::= 'FIXEDPRECISION' //{cons("FIXEDPRECISION")}
IntegerMachineParameter ::= 'FLOATRADIX' //{cons("FLOATRADIX")}
IntegerMachineParameter ::= 'IMPLFLOATPRECISION'
'(' Precision ')' //{cons("IMPLFLOATPRECISION")}
IntegerMachineParameter ::= 'IMPLFIXEDPRECISION'
'(' ScaleSpecifier ','
FractionSpecifier ')' //{cons("IMPLFIXEDPRECISION")}
IntegerMachineParameter ::= 'IMPLINTSIZE'
'(' IntegerSize ')' //{cons("IMPLINTSIZE")}
IntegerMachineParameter ::= 'MAXFLOATPRECISION' //{cons("MAXFLOATPRECISION")}
IntegerMachineParameter ::= 'MAXFIXEDPRECISION' //{cons("MAXFIXEDPRECSION")}
IntegerMachineParameter ::= 'MAXINTSIZE' //{cons("MAXINTSIZE")}
IntegerMachineParameter ::= 'MAXBYTES' //{cons("MAXBYTES")}
IntegerMachineParameter ::= 'MAXBITS' //{cons("MAXBITS")}
IntegerMachineParameter ::= 'MAXINT'
'(' IntegerSize ')' //{cons("MAXINT")}
IntegerMachineParameter ::= 'MININT'
'(' IntegerSize ')' //{cons("MININT")}
IntegerMachineParameter ::= 'MAXTABLESIZE' //{cons("MAXTABLESIZE")}
IntegerMachineParameter ::= 'MAXSTOP' //{cons("MAXSTOP")}
IntegerMachineParameter ::= 'MINSTOP' //{cons("MINSTOP")}
IntegerMachineParameter ::= 'MAXSIGNDIGITS' //{cons("MAXSIGNDIGITS")}
IntegerMachineParameter ::= 'MINSIZE'
'('
CompileTimeNumericFormula
')' //{cons("MINSIZE")}
IntegerMachineParameter ::= 'MINFRACTION'
'('
CompileTimeNumericFormula
')' //{cons("MINFRACTION")}
IntegerMachineParameter ::= 'MINSCALE'
'('
CompileTimeNumericFormula
')' //{cons("MINSCALE")}
IntegerMachineParameter ::= 'MINRELPRECISION'
'('
CompileTimeNumericFormula
')' //{cons("MINRELPRECISION")}
FloatingMachineParameter ::= 'MAXFLOAT'
'(' Precision ')' //{cons("MAXFLOAT")}
FloatingMachineParameter ::= 'MINFLOAT'
'(' Precision ')' //{cons("MINFLOAT")}
FloatingMachineParameter ::= 'FLOATRELPRECISION'
'(' Precision ')' //{cons("FLOATRELPRECISION")}
FloatingMachineParameter ::= 'FLOATUNDERFLOW'
'(' Precision ')' //{cons("FLOATUNDERFLOW")}
FixedMachineParameter ::= 'MAXFIXED'
'('
ScaleSpecifier ','
FractionSpecifier
')' //{cons("MAXFIXED")}
FixedMachineParameter ::= 'MINFIXED'
'('
ScaleSpecifier ','
FractionSpecifier
')' //{cons("MINFIXED")}
//%%%%%%%%%%
//%% 2.0 DECLARATIONS
//%%%%%%%%%%
Declaration ::= DataDeclaration
Declaration ::= TypeDeclaration
Declaration ::= SubroutineDeclaration //{reject} //%% AMBIGUOUS with NonNestedSubroutine
Declaration ::= StatementNameDeclaration
Declaration ::= DefineDeclaration
Declaration ::= ExternalDeclaration
Declaration ::= OverlayDeclaration
Declaration ::= InlineDeclaration
Declaration ::= NullDeclaration
Declaration ::= 'BEGIN'
Declaration+
'END' //{cons("Declaration")}
Declaration ::= Directive
CompoolDeclaration ::= ExternalDeclaration
CompoolDeclaration ::= ConstantDeclaration
CompoolDeclaration ::= TypeDeclaration
CompoolDeclaration ::= DefineDeclaration
CompoolDeclaration ::= OverlayDeclaration
CompoolDeclaration ::= NullDeclaration
CompoolDeclaration ::= 'BEGIN'
CompoolDeclaration+
'END' //{cons("Declaration")} //%% Using Declaration traversals
CompoolDeclaration ::= Directive
//%% 2.1 DATA DECLARATIONS
//%%
DataDeclaration ::= ItemDeclaration
DataDeclaration ::= TableDeclaration
DataDeclaration ::= ConstantDeclaration
DataDeclaration ::= BlockDeclaration
//%% 2.1.1 ITEM DECLARATIONS
//%%
ItemDeclaration ::= 'ITEM' ItemName
OptAllocationSpecifier
ItemTypeDescription
OptItemPreset ';' //{cons("ItemDeclaration")}
ItemName ::= Name
ItemTypeDescription ::= IntegerTypeDescription
ItemTypeDescription ::= FloatingTypeDescription
ItemTypeDescription ::= FixedTypeDescription
ItemTypeDescription ::= BitTypeDescription
ItemTypeDescription ::= CharacterTypeDescription
ItemTypeDescription ::= StatusTypeDescription
ItemTypeDescription ::= PointerTypeDescription
ItemTypeDescription ::= ItemTypeName //{prefer}
//%% Prefer above fixes ambiguity with type names
//%% 2.1.1.1 INTEGER TYPE DESCRIPTIONS
//%%
IntegerTypeDescription ::= IntegerItemDescription
IntegerTypeDescription ::= IntegerTypeName
//%% 'S'
IntegerItemDescription ::= SignedTypeDesc
OptRoundOrTruncate
OptIntegerSize //{cons("IntegerItemDescription")}
//%% 'U'
IntegerItemDescription ::= UnsignedTypeDesc
OptRoundOrTruncate
OptIntegerSize //{cons("IntegerItemDescriptionU")}
IntegerSize ::= CompileTimeNumericFormula //{cons("ItemSize")}
IntegerSize ::= EQ //{reject}
OptIntegerSize ::= IntegerSize
OptIntegerSize ::= /*% empty %*/ //{cons("no-item-size")}
IntegerTypeName ::= ItemTypeName //{cons("TypeName")} //%% using general cons for conversion traversal purposes
//%% 2.1.1.2 FLOATING TYPE DESCRIPTIONS
//%%
FloatingTypeDescription ::= FloatingItemDescription
FloatingTypeDescription ::= FloatingTypeName //{reject} //%% Using ItemTypeName
//%%'F'
FloatingItemDescription ::= FloatingTypeDesc
OptRoundOrTruncate
OptPrecision //{cons("FloatingItemDescription")}
RoundOrTruncate ::= ',' 'R' //{cons("R")}
RoundOrTruncate ::= ',' 'T' //{cons("T")}
RoundOrTruncate ::= ',' 'Z' //{cons("Z")}
OptRoundOrTruncate ::= RoundOrTruncate
OptRoundOrTruncate ::= /*% empty %*/ //{cons("no-round-or-truncate")}
Precision ::= CompileTimeNumericFormula
OptPrecision ::= Precision
OptPrecision ::= /*% empty %*/ //{cons("no-precision")}
FloatingTypeName ::= ItemTypeName
//%% 2.1.1.3 FIXED TYPE DESCRIPTIONS
//%%
FixedTypeDescription ::= FixedItemDescription
FixedTypeDescription ::= FixedTypeName //{reject} //%% Using ItemTypeName
//%% 'A'
FixedItemDescription ::= FixedTypeDesc
OptRoundOrTruncate
ScaleSpecifier
OptFractionSpecifier //{cons("FixedItemDescription")}
ScaleSpecifier ::= CompileTimeNumericFormula //{cons("ScaleSpecifier")}
ScaleSpecifier ::= EQ //{reject}
FractionSpecifier ::= CompileTimeNumericFormula //{cons("FractionSpecifier")}
FractionSpecifier ::= EQ //{reject}
//%% What to do here
OptFractionSpecifier ::= ',' FractionSpecifier //{cons("OptFractionSpecifier")}
OptFractionSpecifier ::= /*% empty %*/ //{cons("no-fraction-specifier")}
FixedTypeName ::= ItemTypeName
//%% 2.1.1.4 BIT TYPE DESCRIPTIONS
//%%
BitTypeDescription ::= BitItemDescription
BitTypeDescription ::= BitTypeName //{reject} //%% Using ItemTypeName
//%% 'B'
BitItemDescription ::= BitTypeDesc
OptBitSize //{cons("BitItemDescription")}
BitSize ::= CompileTimeNumericFormula //{cons("ItemSize")}
BitSize ::= EQ //{reject}
OptBitSize ::= BitSize
OptBitSize ::= /*% empty %*/ //{cons("no-item-size")}
BitTypeName ::= ItemTypeName
//%% 2.1.1.5 CHARACTER TYPE DESCRIPTIONS
//%%
CharacterTypeDescription ::= CharacterItemDescription
CharacterTypeDescription ::= CharacterTypeName //{reject} //%% Using ItemTypeName
//%% 'C'
CharacterItemDescription ::= CharacterTypeDesc
OptCharacterSize //{cons("CharacterItemDescription")}
CharacterSize ::= CompileTimeNumericFormula //{cons("ItemSize")}
CharacterSize ::= EQ //{reject}
OptCharacterSize ::= CharacterSize
OptCharacterSize ::= /*% empty %*/ //{cons("no-item-size")}
CharacterTypeName ::= ItemTypeName
//%% 2.1.1.6 STATUS TYPE DESCRIPTIONS
//%%
StatusTypeDescription ::= StatusItemDescription
StatusTypeDescription ::= StatusTypeName //{reject} //%% Using ItemTypeName
StatusItemDescription ::= 'STATUS' OptStatusSize
'(' StatusList ')' //{cons("StatusItemDescription")}
StatusList ::= DefaultSublist
StatusList ::= OptDefaultSublist
//{SpecifiedSublist ','}+ //{cons("StatusList")}
//{StatusConstant ','}+ -> DefaultSublist //{cons("DefaultSublist")}
OptDefaultSublist ::= DefaultSublist ',' //{cons("OptDefaultSublist")}
OptDefaultSublist ::= /*% empty %*/ //{cons("no-default-sublist")}
SpecifiedSublist ::= StatusListIndex
//{StatusConstant ','}+ //{cons("SpecifiedSublist")}
StatusListIndex ::= CompileTimeNumericFormula
StatusConstant ::= 'V' '(' Status ')' //{cons("StatusConstant")}
Status ::= Name
Status ::= Letter
Status ::= ReservedWord //{prefer} //%%fixes ambiguity between Name and ReservedWord
StatusTypeName ::= ItemTypeName
StatusSize ::= CompileTimeNumericFormula //{cons("ItemSize")}
OptStatusSize ::= StatusSize
OptStatusSize ::= /*% empty %*/ //{cons("no-item-size")}
//%% 2.1.1.7 POINTER TYPE DESCRIPTIONS
//%%
PointerTypeDescription ::= PointerItemDescription
PointerTypeDescription ::= PointerTypeName //{reject} //%% Using ItemTypeName
//%% 'P'
PointerItemDescription ::= PointerTypeDesc
OptTypeName //{cons("PointerItemDescription")}
PointerTypeName ::= ItemTypeName //{cons("PointerTypeName")}
TypeName ::= ItemTypeName //{prefer} //%%fixes ambiguity between ItemTypeName, TableTypeName, and BlockTypeName
TypeName ::= TableTypeName
TypeName ::= BlockTypeName
OptTypeName ::= TypeName //{cons("TypeName")}
OptTypeName ::= /*% empty %*/ //{cons("no-type-name")}
//%% 2.1.2 TABLE DECLARATIONS
//%%
TableDeclaration ::= 'TABLE' TableName
OptAllocationSpecifier
OptDimensionList
TableDescription //{cons("TableDeclaration")}
TableDescription ::= OptStructureSpecifier
EntrySpecifier //{cons("TableDescription")}
TableDescription ::= TableTypeName
OptTablePreset ';' //{prefer, cons("TableDescriptionName")} //%% removes ambiguity with other production of TableDescription
EntrySpecifier ::= OrdinaryEntrySpecifier
EntrySpecifier ::= SpecifiedEntrySpecifier
TableName ::= Name
//%% 2.1.2.1 TABLE DIMENSION LISTS
//%%
DimensionList ::= '(' //{Dimension ','}+ ')' //{cons("DimensionList")}
OptDimensionList ::= DimensionList
OptDimensionList ::= /*% empty %*/ //{cons("no-dimension-list")}
Dimension ::= OptLowerBoundOption
UpperBound //{cons("Dimension")}
Dimension ::= '*' //{cons("DimensionSTAR")}
LowerBoundOption ::= LowerBound ':' //{cons("LowerBoundOption")}
OptLowerBoundOption ::= LowerBoundOption
OptLowerBoundOption ::= /*% empty %*/ //{cons("no-lower-bound-option")}
LowerBound ::= CompileTimeNumericFormula
UpperBound ::= CompileTimeNumericFormula
//%% 2.1.2.2 TABLE STRUCTURE
//%%
StructureSpecifier ::= 'PARALLEL' //{cons("StructureSpecifier")}
//%% 'T'
StructureSpecifier ::= StrucSpecT
OptBitsPerEntry //{cons("StructureSpecifierT")}
OptStructureSpecifier ::= StructureSpecifier
OptStructureSpecifier ::= /*% empty %*/ //{cons("no-structure-specifier")}
BitsPerEntry ::= CompileTimeNumericFormula
OptBitsPerEntry ::= BitsPerEntry
OptBitsPerEntry ::= /*% empty %*/ //{cons("no-bits-per-entry")}
//%% 2.1.2.3 ORDINARY TABLE ENTRIES
//%%
OrdinaryEntrySpecifier ::= OptPackingSpecifier
ItemTypeDescription
OptTablePreset ';' //{cons("OrdinaryEntrySpecifier")}
OrdinaryEntrySpecifier ::= OptPackingSpecifier
OptTablePreset ';'
OrdinaryTableBody //{cons("OrdinaryEntrySpecifierBody")}
PackingSpecifier ::= NPackSpec //{cons("PackingSpecifier")}
PackingSpecifier ::= MPackSpec //{cons("PackingSpecifier")}
PackingSpecifier ::= DPackSpec //{cons("PackingSpecifier")}
OrdinaryTableBody ::= OrdinaryTableItemDeclaration
OrdinaryTableBody ::= 'BEGIN'
OrderDirective*
OrdinaryTableOptions+
'END' //{cons("OrdinaryTableBody")}
OptPackingSpecifier ::= PackingSpecifier
OptPackingSpecifier ::= /*% empty %*/ //{cons("no-packing-specifier")}
OrdinaryTableItemDeclaration ::= 'ITEM' TableItemName
ItemTypeDescription
OptPackingSpecifier
OptTablePreset ';' //{cons("OrdinaryTableItemDeclaration")}
TableItemName ::= Name
OrdinaryTableOptions ::= OrdinaryTableItemDeclaration
OrdinaryTableOptions ::= NullDeclaration
//%% 2.1.2.4 SPECIFIED TABLE ENTRIES
//%%
SpecifiedEntrySpecifier ::= WordsPerEntry
SpecifiedItemDescription
OptTablePreset ';' //{cons("SpecifiedEntrySpecifier")}
SpecifiedEntrySpecifier ::= WordsPerEntry
OptTablePreset ';'
SpecifiedTableBody //{cons("SpecifiedEntrySpecifierBody")}
WordsPerEntry ::= 'W' OptEntrySize //{cons("WordsPerEntryW")}
WordsPerEntry ::= 'V' //{cons("WordsPerEntryV")}
EntrySize ::= CompileTimeNumericFormula
EntrySize ::= EQ //{reject}
OptEntrySize ::= EntrySize
OptEntrySize ::= /*% empty %*/ //{cons("no-entry-size")}
SpecifiedItemDescription ::= ItemTypeDescription 'POS'
'(' LocationSpecifier ')' //{cons("SpecifiedItemDescription")}
LocationSpecifier ::= StartingBit ',' StartingWord //{cons("LocationSpecifier")}
StartingBit ::= CompileTimeNumericFormula
StartingBit ::= '*' //{cons("StartingBitSTAR")}
StartingWord ::= CompileTimeNumericFormula
SpecifiedTableBody ::= SpecifiedTableItemDeclaration
SpecifiedTableBody ::= 'BEGIN'
SpecifiedTableOptions+
'END' //{cons("SpecifiedTableBody")}
SpecifiedTableItemDeclaration ::= 'ITEM' TableItemName
SpecifiedItemDescription
OptTablePreset ';'
//{cons("SpecifiedTableItemDeclaration")}
SpecifiedTableOptions ::= SpecifiedTableItemDeclaration
SpecifiedTableOptions ::= NullDeclaration
//%% 2.1.3 CONSTANT DECLARATIONS
//%%
ConstantDeclaration ::= 'CONSTANT' 'ITEM'
ConstantItemName
ItemTypeDescription
ItemPreset ';' //{cons("ConstantItemDeclaration")}
ConstantDeclaration ::= 'CONSTANT' 'TABLE'
ConstantTableName
OptDimensionList
TableDescription //{cons("ConstantTableDeclaration")}
ConstantItemName ::= Name
ConstantTableName ::= Name
//%% 2.1.4 BLOCK DECLARATIONS
//%%
BlockDeclaration ::= 'BLOCK' BlockName
OptAllocationSpecifier ';'
BlockBodyPart //{cons("BlockDeclarationBodyPart")}
BlockDeclaration ::= 'BLOCK' BlockName
OptAllocationSpecifier
BlockTypeName
OptBlockPreset ';' //{cons("BlockDeclarationTypeName")}
BlockName ::= Name //{cons("Name")}
BlockBodyPart ::= NullDeclaration
BlockBodyPart ::= DataDeclaration
BlockBodyPart ::= 'BEGIN'
OrderDirective*
BlockBodyOptions+
'END' //{cons("BlockBodyPart")}
BlockBodyOptions ::= DataDeclaration
BlockBodyOptions ::= OverlayDeclaration
BlockBodyOptions ::= NullDeclaration
//%% 2.1.5 ALLOCATION OF DATA OBJECTS
//%%
AllocationSpecifier ::= 'STATIC' //{cons("STATIC")}
OptAllocationSpecifier ::= AllocationSpecifier
OptAllocationSpecifier ::= /*% empty %*/ //{cons("no-allocation-specifier")}
//%% 2.1.6 INITIALIZATION OF DATA OBJECTS
//%%
ItemPreset ::= '=' ItemPresetValue //{cons("ItemPreset")}
OptItemPreset ::= ItemPreset
OptItemPreset ::= /*% empty %*/ //{cons("no-item-preset")}
ItemPresetValue ::= CompileTimeNumericFormula //{prefer}
ItemPresetValue ::= LocFunction
//%%Added UserDefinedFunctionCall to remove ambiguities
//%% when there is a PresetValuesOption that is a TableItem
//%% TableItems can only be parsed as UserDefinedFunctionCall
OptItemPresetValue ::= FunctionCall //{prefer}
OptItemPresetValue ::= ItemPresetValue
ItemPresetValue ::= /*% empty %*/ //{cons("no-item-preset-value")}
//%% The grammar for table and block presets departs from the standard in
//%% order to produce a single list (rather than a wierd list of lists). This
//%% is hinted as in standard examples and is helpful for a list with
//%% empty members, e.g., [1,,3,4]
//%%
TablePreset ::= '=' TablePresetList //{cons("TablePreset")}
OptTablePreset ::= TablePreset
OptTablePreset ::= /*% empty %*/ //{cons("no-table-preset")}
//{PresetValue ','}+ -> TablePresetList //{cons("TablePresetList")}
PresetValue ::= /*% empty %*/ //{cons("PresetValueNone")}
PresetValue ::= Formula
PresetValue ::= RepetitionCount
'('
//{PresetValue ','}+
')' //{cons("PresetValueRep")}
PresetValue ::= PresetValuePositioner
PresetValuePositioner ::= 'POS'
'('
//{ConstantIndex ','}+
')'
':' PresetValue //{cons("PresetValuePositioner")}
ConstantIndex ::= CompileTimeNumericFormula
RepetitionCount ::= CompileTimeNumericFormula
BlockPreset ::= '=' BlockPresetList //{cons("BlockPreset")}
OptBlockPreset ::= BlockPreset
OptBlockPreset ::= /*% empty %*/ //{cons("no-block-preset")}
//{BlockPresetValue ','}+ -> BlockPresetList //{cons("BlockPresetList")}
BlockPresetValue ::= PresetValue
BlockPresetValue ::= '(' TablePresetList ')' //{cons("BlockPresetValueParens")}
//%%'(' BlockPresetList ')' -> BlockPresetValue //%% AMBIGUOUS
//%% 2.2 TYPE DECLARATIONS
//%%
TypeDeclaration ::= ItemTypeDeclaration
TypeDeclaration ::= TableTypeDeclaration
TypeDeclaration ::= BlockTypeDeclaration
ItemTypeDeclaration ::= 'TYPE' ItemTypeName
ItemTypeDescription ';' //{cons("ItemTypeDeclaration")}
ItemTypeName ::= Name //{cons("Name")}
TableTypeDeclaration ::= 'TYPE' TableTypeName
'TABLE' TableTypeSpecifier //{cons("TableTypeDeclaration")}
TableTypeSpecifier ::= OptDimensionList
OptStructureSpecifier
OptLikeOption
EntrySpecifier //{cons("TableTypeSpecifier")}
TableTypeSpecifier ::= OptDimensionList
TableTypeName ';' //{cons("TableTypeSpecifierName"), prefer}
TableTypeName ::= Name //{cons("Name")}
LikeOption ::= 'LIKE' TableTypeName //{cons("LikeOption")}
OptLikeOption ::= LikeOption
OptLikeOption ::= /*% empty %*/ //{cons("no-like-option")}
BlockTypeDeclaration ::= 'TYPE' BlockTypeName
'BLOCK' BlockBodyPart //{cons("BlockTypeDeclaration")}
BlockTypeName ::= Name //{cons("Name")}
//%% 2.3 STATEMENT NAME DECLARATIONS
//%%
StatementNameDeclaration ::= 'LABEL' //{StatementName ','}+ ';' //{cons("StatementNameDeclaration")}
//%% 2.4 DEFINE DECLARATIONS
//%%
DefineDeclaration ::= 'DEFINE' DefineName
DefinitionPart //{cons("DefineDeclaration")}
DefineName ::= Name //{cons("Name")}
DefinitionPart ::= OptFormalDefineParameterList
DefineString ';' //{cons("DefinitionPart")}
FormalDefineParameterList ::= '('
//{FormalDefineParameter ','}+
')' //{cons("FormalDefineParameterList")}
OptFormalDefineParameterList ::= FormalDefineParameterList
OptFormalDefineParameterList ::= /*% empty %*/ //{cons("no-formal-define-parameter-list")}
FormalDefineParameter ::= Letter //{cons("FormalDefineParameter")}
//%% Moved to lexical analysis
//%%'?'
//%% //{Character ','}*
//%%'?' -> DefineString //{cons("DefineString")}
DefineString ::= DefString //{cons("DefineString")}
//%% 2.4.1 DEFINE CALLS
//%%
DefineCall ::= DefineName
ActualDefineParameterList //{cons("DefineCall")}
DefineCall ::= DefineName
NoList //{cons("DefineCall")}
ActualDefineParameterList ::= '('
//{ActualDefineParameter ','}+
')' //{cons("ActualDefineParameterList")}
NoList ::= /*% empty %*/ //{cons("no-list")}
ActualDefineParameter ::= Character*
ActualDefineParameter ::= '"' Character* '"' //{cons("quoted-string")}
//%% 2.5 EXTERNAL DECLARATIONS
//%%
ExternalDeclaration ::= DefSpecification
ExternalDeclaration ::= RefSpecification
//%% 2.5.1 DEF SPECIFICATIONS
//%%
DefSpecification ::= SimpleDef
DefSpecification ::= CompoundDef
SimpleDef ::= 'DEF'
DefSpecificationChoice //{cons("SimpleDef")}
CompoundDef ::= 'DEF' 'BEGIN'
DefSpecificationChoice+
'END' //{cons("CompoundDef")}
DefSpecificationChoice ::= NullDeclaration
DefSpecificationChoice ::= DataDeclaration
DefSpecificationChoice ::= DefBlockInstantiation
DefSpecificationChoice ::= StatementNameDeclaration
//%%Not originally in grammar
DefSpecificationChoice ::= OverlayDeclaration
DefBlockInstantiation ::= 'BLOCK' 'INSTANCE'
BlockName ';' //{cons("DefBlockInstantiation")}
//%% 2.5.2 REF SPECIFICATIONS
//%%
RefSpecification ::= SimpleRef
RefSpecification ::= CompoundRef
SimpleRef ::= 'REF'
RefSpecificationChoice //{cons("SimpleRef")}
CompoundRef ::= 'REF' 'BEGIN'
RefSpecificationChoice+
'END' //{cons("CompoundRef")}
RefSpecificationChoice ::= NullDeclaration
RefSpecificationChoice ::= DataDeclaration
RefSpecificationChoice ::= SubroutineDeclaration
RefSpecificationChoice ::= StatementNameDeclaration
//%% 2.6 OVERLAY DECLARATIONS
//%%
OverlayDeclaration ::= 'OVERLAY'
OptAbsoluteAddress
OverlayExpression ';' //{cons("OverlayDeclaration")}
AbsoluteAddress ::= 'POS' '(' OverlayAddress ')' //{cons("AbsoluteAddress")}
OptAbsoluteAddress ::= AbsoluteAddress
OptAbsoluteAddress ::= /*% empty %*/ //{cons("no-absolute-address")}
OverlayAddress ::= CompileTimeNumericFormula
//{OverlayString ':'}+ -> OverlayExpression
//{OverlayElement ','}+ -> OverlayString
OverlayElement ::= Spacer
OverlayElement ::= DataName
OverlayElement ::= '(' OverlayExpression ')' //{cons("OverlayElement")}
Spacer ::= 'W' CompileTimeNumericFormula //{cons("Spacer")}
DataName ::= Name //{cons("Name"), prefer}
DataName ::= ItemName
DataName ::= TableName
DataName ::= BlockName
//%% 2.7 NULL DECLARATIONS
//%%
NullDeclaration ::= ';' //{cons("NullDeclaration")}
NullDeclaration ::= 'BEGIN' 'END' //{cons("NullDeclaration")}
//%%%%%%%%%%
//%% 3.0 PROCEDURES AND FUNCTIONS
//%%%%%%%%%%
SubroutineDeclaration ::= ProcedureDeclaration //{prefer}
SubroutineDeclaration ::= FunctionDeclaration //%% AMBIGUOUS with ProcedureDeclaration
SubroutineDefinition ::= ProcedureDefinition //{prefer}
SubroutineDefinition ::= FunctionDefinition //%% AMBIGUOUS with ProcedureDefinition
//%% 3.1 PROCEDURES
//%%
ProcedureDeclaration ::= ProcedureHeading ';'
PostProcDirective*
Declaration //{cons("ProcedureDeclaration")}
ProcedureDefinition ::= ProcedureHeading ';'
PostProcDirective*
ProcedureBody //{cons("ProcedureDefinition")}
ProcedureHeading ::= 'PROC'
ProcedureName
OptSubroutineAttribute
OptFormalParameterList //{cons("ProcedureHeading")}
SubroutineAttribute ::= 'REC' //{cons("REC")}
SubroutineAttribute ::= 'RENT' //{cons("RENT")}
OptSubroutineAttribute ::= SubroutineAttribute
OptSubroutineAttribute ::= /*% empty %*/ //{cons("no-subroutine-attribute")}
ProcedureName ::= Name //{cons("Name")}
ProcedureBody ::= SubroutineBody
SubroutineBody ::= Statement //{cons("SubroutineSimpleBody")}
SubroutineBody ::= 'BEGIN'
//%% Directive* has been moved from the original grammar to DeclarationList
DeclarationList
Statement*
SubroutineDefinition*
LabelList
'END' //{cons("SubroutineBody"), prefer}
//%% 3.2 FUNCTIONS
//%%
FunctionDeclaration ::= FunctionHeading ';'
PostProcDirective*
Declaration //{cons("FunctionDeclaration")}
FunctionDefinition ::= FunctionHeading ';'
PostProcDirective*
FunctionBody //{cons("FunctionDefinition")}
FunctionHeading ::= 'PROC'
FunctionName
OptSubroutineAttribute
OptFormalParameterList
ItemTypeDescription //{cons("FunctionHeading")}
FunctionName ::= Name //{cons("Name")}
FunctionBody ::= SubroutineBody
//%% 3.3 PARAMETERS OF PROCEDURES AND FUNCTIONS
//%%
FormalParameterList ::= '('
//{FormalInputParameter ','}*
OptFormalOutputParameter
')' //{cons("FormalParameterList")}
OptFormalParameterList ::= FormalParameterList
OptFormalParameterList ::= /*% empty %*/ //{cons("no-formal-parameter-list")}
OptFormalOutputParameter ::= ':' //{FormalOutputParameter','}+ //{cons("FormalOutputParameterList")}
OptFormalOutputParameter ::= /*% empty %*/ //{cons("no-formal-output-parameters")}
FormalInputParameter ::= OptParameterBinding
InputParameterName //{cons("FormalInputParameter")}
FormalOutputParameter ::= OptParameterBinding
OutputParameterName //{cons("FormalOutputParameter")}
ParameterBinding ::= 'BYVAL' //{cons("BYVAL")}
ParameterBinding ::= 'BYREF' //{cons("BYREF")}
ParameterBinding ::= 'BYRES' //{cons("BYRES")}
OptParameterBinding ::= ParameterBinding
OptParameterBinding ::= /*% empty %*/ //{cons("no-parameter-binding")}
InputParameterName ::= Name //{cons("Name"), prefer} //%% added this production and prefer to remove ambiguity within InputParameterName
InputParameterName ::= DataName
InputParameterName ::= StatementName
InputParameterName ::= SubroutineName
OutputParameterName ::= Name //{cons("Name"), prefer}
OutputParameterName ::= DataName
SubroutineName ::= Name //{cons("Name"), prefer}
SubroutineName ::= ProcedureName
SubroutineName ::= FunctionName
//%% 3.4 INLINE PROCEDURES AND FUNCTIONS
//%%
InlineDeclaration ::= 'INLINE'
//{SubroutineName ','}+ ';' //{cons("InlineDeclaration")}
//%% 3.5 MACHINE-SPECIFIC PROCEDURES AND FUNCTIONS
//%%
//%%%%%%%%%%
//%% 4.0 STATEMENTS
//%%%%%%%%%%
Statement ::= LabelList SimpleStatement //{cons("SimpleStatement")}
Statement ::= LabeledSimpleStatement //{cons("SimpleStatement")}
Statement ::= LabeledCompoundStatement
SimpleStatement ::= AssignmentStatement
LabeledSimpleStatement ::= LoopStatement
LabeledSimpleStatement ::= IfStatement
LabeledSimpleStatement ::= CaseStatement
LabeledSimpleStatement ::= ProcedureCallStatement
LabeledSimpleStatement ::= ReturnStatement
LabeledSimpleStatement ::= GotoStatement
LabeledSimpleStatement ::= ExitStatement
LabeledSimpleStatement ::= StopStatement
LabeledSimpleStatement ::= AbortStatement
SimpleStatement ::= NullStatement
NullStatement ::= ';' //{cons("NullStatement")}
NullStatement ::= 'BEGIN'
LabelList
'END' //{cons("NullBlockStatement")}
//%% StatementName changed to Name when cons("Name") was added to StatementName
//%% Otherwise terms like Name(Label("label_string")) would appear.
//%%
//%% StatementName ':' -> Label //{cons("Label")}
//%%
Label ::= Name ':' //{cons("Label")}
LabelList ::= Label* //{cons("LabelList")}
StatementName ::= Name //{cons("Name")}
LabeledCompoundStatement ::= LabelList
'BEGIN'
Statement+
LabelList
'END' //{cons("CompoundStatement")}
//%% 4.1 ASSIGNMENT STATEMENTS
//%%
AssignmentStatement ::= VariableList
'=' Formula ';' //{cons("AssignmentStatement")}
//{Variable ','}+ -> VariableList //{cons("VariableList")}
//{TableItemNoDeref ','}+ -> VariableList //{cons("VariableList")}
//%% 4.2 LOOP STATEMENTS
//%%
LoopStatement ::= LabelList
WhileClause ControlledStatement //{cons("WhileStatement")}
LoopStatement ::= LabelList
ForClause ControlledStatement //{cons("ForStatement")}
LoopType ::= WhileClause
LoopType ::= ForClause
ControlledStatement ::= Statement
WhileClause ::= 'WHILE' Formula ';' //{cons("WhileClause")}
ForClause ::= 'FOR' ControlItem ':'
ControlClause ';' //{cons("ForClause")}
ControlItem ::= ControlVariable
ControlItem ::= ControlLetter
ControlVariable ::= ItemName
ControlClause ::= InitialValue
OptContinuation //{cons("ControlClause")}
InitialValue ::= Formula
Continuation ::= ByOrThenPhrase
OptWhilePhrase //{cons("Continuation")}
Continuation ::= WhilePhrase
OptByOrThenPhrase //{cons("Continuation")}
OptContinuation ::= Continuation
OptContinuation ::= /*% empty %*/ //{cons("no-continuation")}
ByOrThenPhrase ::= ByPhrase
ByOrThenPhrase ::= ThenPhrase
OptByOrThenPhrase ::= ByOrThenPhrase
OptByOrThenPhrase ::= /*% empty %*/ //{cons("no-by-or-then-phrase")}
ByPhrase ::= 'BY' ByFormula //{cons("ByPhrase")}
ByFormula ::= Formula //%% generalized to Formula after removal of NumericFormula
ThenPhrase ::= 'THEN' Formula //{cons("ThenPhrase")}
WhilePhrase ::= 'WHILE' Formula //{cons("WhilePhrase")}
OptWhilePhrase ::= WhilePhrase
OptWhilePhrase ::= /*% empty %*/ //{cons("no-while-phrase")}
//%% 4.3 IF STATEMENTS
//%%
IfStatement ::= LabelList
IfKeyword Formula ';' //%% Generalized to Formula after changes to formulas
ConditionalStatement
OptElseClause //{cons("IfStatement")}
ConditionalStatement ::= Statement
ElseClause ::= 'ELSE' Statement //{cons("ElseClause")}
OptElseClause ::= ElseClause
OptElseClause ::= /*% empty %*/ //{cons("no-else-clause")}
//%% 4.4 CASE STATEMENTS
//%%
CaseStatement ::= LabelList
'CASE'
CaseSelectorFormula ';'
'BEGIN'
CaseBody
LabelList
'END' //{cons("CaseStatement")}
//%% Generalized to Formula
//%% Grammar allows for Integer, Bit, Character, and Status Formulas
CaseSelectorFormula ::= Formula
CaseBody ::= CaseAlternative+
CaseAlternative ::= CaseIndexGroup
Statement
OptFALLTHRU //{cons("CaseAlternative")}
CaseAlternative ::= DefaultOption //{prefer}
DefaultOption ::= '(' 'DEFAULT' ')' ':'
Statement
OptFALLTHRU //{cons("DefaultOption")}
OptFALLTHRU ::= 'FALLTHRU' //{cons("FALLTHRU")}
OptFALLTHRU ::= /*% empty %*/ //{cons("no-fall-thru")}
CaseIndexGroup ::= '(' //{CaseIndex ','}+ ')' ':' //{cons("CaseIndexGroup")}
CaseIndex ::= CompileTimeNumericFormula //{cons("CaseIndex"), prefer}
CaseIndex ::= LowerBound ':' UpperBound //{cons("CaseIndex")}
//%% 4.5 PROCEDURE CALL STATEMENTS
//%%
ProcedureCallStatement ::= UserDefinedProcedureCall //{prefer}
ProcedureCallStatement ::= MachineSpecificProcedureCall //%% rejected below
UserDefinedProcedureCall ::= LabelList ProcedureName
OptActualParameterList
OptAbortPhrase ';' //{cons("ProcedureCallStatement")}
OptAbortPhrase ::= AbortPhrase
OptAbortPhrase ::= /*% empty %*/ //{cons("no-abort-phrase")}
ActualParameterList ::= '('
//{ActualInputParameter ','}*
OptActualOutputParameters
')' //{cons("ActualParameterList")}
OptActualParameterList ::= ActualParameterList
OptActualParameterList ::= /*% empty %*/ //{cons("no-actual-parameter-list")}
OptActualOutputParameters ::= ':' //{ActualOutputParameter ','}+ //{cons("ActualOutputParameters")}
OptActualOutputParameters ::= /*% empty%*/ //{cons("no-actual-output-parameters")}
//%%Formula used to avoid ambuiguities
//%%Grammar originally allows for Formula, StatementName, FunctionName, ProcedureName, BlockReference
ActualInputParameter ::= Formula //{prefer}
ActualOutputParameter ::= Variable //{cons("Variable"), prefer}
ActualOutputParameter ::= BlockReference //{cons("BlockReference")}
//%% Added UserDefinedFunctionCall to allow for TableItems that can't produce Variable because of ambiguities
ActualOutputParameter ::= UserDefinedFunctionCall
AbortPhrase ::= 'ABORT' StatementName //{cons("AbortPhrase")}
MachineSpecificProcedureCall ::= ProcedureName
OptActualParameterList //{cons("MachineSpecificProcedureCall"), reject} //%%AMBIGUOUS
ProcedureName ::= Name
ProcedureName ::= 'RETURN' //{reject} //%% Ambiguous with ReturnStatement
ProcedureName ::= 'EXIT' //{reject} //%% Ambiguous with ExitStatement
ProcedureName ::= 'STOP' //{reject} //%% Ambiguous with StopStatement
ProcedureName ::= 'ABORT' //{reject} //%% Ambiguous with AbortStatement
FunctionName ::= Name
//%% 4.6 RETURN STATEMENTS
//%%
ReturnStatement ::= LabelList 'RETURN' ';' //{cons("ReturnStatement")}
//%% 4.7 GOTO STATEMENTS
//%%
GotoStatement ::= LabelList 'GOTO' StatementName ';' //{cons("GotoStatement")}
//%% 4.8 EXIT STATEMENTS
//%%
ExitStatement ::= LabelList 'EXIT' ';' //{cons("ExitStatement")}
//%% 4.9 STOP STATEMENTS
//%%
StopStatement ::= LabelList 'STOP' OptFormula ';' //{cons("StopStatement")}
OptFormula ::= Formula
OptFormula ::= /*% empty %*/ //{cons("no-integer-formula")} //%% should be no-numeric-formula? Will keep as is for now
//%% 4.10 ABORT STATEMENTS
//%%
AbortStatement ::= LabelList 'ABORT' ';' //{cons("AbortStatement")}
//%%%%%%%%%%
//%% 5.0 FORMULAS
//%%%%%%%%%%
//%% Most formulas will go through Level4Expr -> Formula, but some conversions and some others
//%% will go through these productions
//%% StatusFormula -> Formula
//%% All CompileTimeFormulas will use this production to remove ambiguities
CompileTimeNumericFormula ::= Formula //%% new Jan.11
//%% 5.1 NUMERIC FORMULAS (expression hierarchy derived from Fortran)
//%%
//%% Restructuring of NumericFormula has removed
//%% IntegerTerm, IntegerFactor, IntegerPrimary, IntegerVariable
//%% NamedIntegerConstant, IntegerFunctionCall, IntegerFormula
//%% FloatingTerm, FloatingFactor, FloatingPrimary, FloatingVariable
//%% NamedFloatingConstant, FloatingFunctionCall, FloatingFormula
//%% FixedTerm, FixedFactor, FixedVariable
//%% NamedFixedConstant, FixedFunctionCall, FixedFormula
//%% Sign, PlusOrMinus, MultiplyDivideOrMod
Primary ::= Literal
Primary ::= FunctionCall //{prefer}
Primary ::= Variable
Primary ::= '(' Formula ')' //{cons("Parens")}
Primary ::= StatusConstant //{cons("StatusFormula")}
Primary ::= Conversion
Primary ::= NumericMachineParameter
Level1Expr ::= Primary
Level1Expr ::= ControlLetter
MultOperand ::= Level1Expr
MultOperand ::= Level1Expr '**' MultOperand //{cons("Power")}
AddOperand ::= MultOperand
AddOperand ::= AddOperand '*' MultOperand //{cons("Mult")}
AddOperand ::= AddOperand '/' MultOperand //{cons("Div")}
AddOperand ::= AddOperand MODOperator MultOperand //{cons("Mod")}
Level2Expr ::= AddOperand
Level2Expr ::= '+' AddOperand //{cons("UnaryPlus"), prefer}
Level2Expr ::= '-' AddOperand //{cons("UnaryMinus"), prefer}
Level2Expr ::= Level2Expr '+' AddOperand //{cons("Plus")}
Level2Expr ::= Level2Expr '-' AddOperand //{cons("Minus")}
Level3Expr ::= Level2Expr //%% for concatenation operator in Fortran
EQ ::= Level2Expr '=' Level2Expr //{cons("EQ")}
EQ ::= UserDefinedFunctionCall
'=' Level2Expr //{cons("EQ"), prefer}
Level3Expr ::= EQ
Level3Expr ::= Level2Expr '<' Level2Expr //{cons("LT")}
Level3Expr ::= Level2Expr '>' Level2Expr //{cons("GT")}
Level3Expr ::= Level2Expr '<=' Level2Expr //{cons("LE")}
Level3Expr ::= Level2Expr '>=' Level2Expr //{cons("GE")}
Level3Expr ::= Level2Expr '<>' Level2Expr //{cons("NE")}
AndOperand ::= Level3Expr
AndOperand ::= 'NOT' Level3Expr //{cons("NOT")}
LogicalOperand ::= AndOperand
//%% 'AND', 'OR', 'EQV', 'XOR' moved to lexer
LogicalOperand ::= LogicalOperand ANDOperator AndOperand //{cons("AND")}
LogicalOperand ::= LogicalOperand OROperator AndOperand //{cons("OR")}
LogicalOperand ::= LogicalOperand EQVOperator AndOperand //{cons("EQV")}
LogicalOperand ::= LogicalOperand XOROperator AndOperand //{cons("XOR")}
Level4Expr ::= LogicalOperand
Formula ::= Level4Expr //{prefer}
//%%Conversions have all been moved here
Conversion ::= IntegerConversion
'(' Formula ')' //{cons("NumericConversion")}
Conversion ::= FloatingConversion
'(' Formula ')' //{cons("NumericConversion")}
Conversion ::= FixedConversion
'(' Formula ')' //{cons("NumericConversion"), prefer}
Conversion ::= BitConversion
'(' Formula ')' //{cons("BitPrimaryConversion")}
Conversion ::= CharacterConversion
'(' Formula ')' //{cons("CharacterFormulaConversion")}
Conversion ::= StatusConversion
'(' Formula ')' //{cons("StatusFormulaConversion")}
Conversion ::= PointerConversion
'(' Formula ')' //{cons("PointerFormulaConversion")}
Conversion ::= TableConversion
'(' Formula ')' //{cons("TableFormulaConversion")}
NumericMachineParameter ::= IntegerMachineParameter
NumericMachineParameter ::= FloatingMachineParameter
NumericMachineParameter ::= FixedMachineParameter
//%% 5.2 BIT FORMULAS
//%%
//%%LogicalOperand, LogicalContinuation, RelationalExpression moved to Level4Expr
//%%NamedBitConstant, like all constants, will be a Name or a Variable
//%%BitConversion moved to Conversion which produces Primary
//%%BitVariable, BitFunctionCall not accessible and will go through more general productions
BitPrimary ::= BitLiteral
BitPrimary ::= BooleanLiteral
//%% 5.2.1 RELATIONAL EXPRESSIONS
//%%
//%% All RelationalExpressions have been moved to Level3Expr in 5.1
//%% 5.2.2 BOOLEAN FORMULAS
//%%
//%%BitFormula -> BooleanFormula
BooleanFormula ::= Formula
//%% 5.3 CHARACTER FORMULAS
//%%
//%%CharacterLiteral, CharacterVariable, NamedCharacterConstant
//%%CharacterConversion moved to Conversion which produces Primary
//%%CharacterFunctionCall not accessible and will go through more general productions
//%% 5.4 STATUS FORMULAS
//%%
//%%StatusConstant moved to Primary
//%%StatusConversion moved to Conversion which produces Primary
//%%StatusVariable, NamedStatusConstant, StatusFunctionCall not accessible
//%%and will go through more general productions
//%% 5.5 POINTER FORMULAS
//%%
//%%PointerLiteral has been moved to Formula
//%%PointerConversion moved to Conversion which produces Primary
//%%PointerVariable, NamedPointerConstant, PointerFunctionCall not accessible
//%%and will go through more general productions
//%% 5.6 TABLE FORMULAS
//%%
//%%TableConversion moved to Conversion which produces Primary
//%%TableVariable, NamedTableConstant not accessible
//%%and will go through more general productions
//%%%%%%%%%%
//%% 6.0 DATA REFERENCES
//%%%%%%%%%%
//%% 6.1 VARIABLE AND BLOCK REFERENCES
//%%
Variable ::= NamedVariable
Variable ::= BitFunctionVariable
Variable ::= ByteFunctionVariable
Variable ::= RepFunctionVariable
//%%FunctionName -> Variable //{reject} //%% AMBIGUOUS with NamedVariable
NamedVariable ::= Item
NamedVariable ::= Table
NamedVariable ::= TableItem //{prefer}
NamedVariable ::= TableEntry
NamedVariable ::= BlockItem //{reject} //%% AMBIGUOUS with BlockTable
NamedVariable ::= BlockTable
NamedVariable ::= BlockTableItem //{reject} //%% AMBIGUOUS with TableItem
NamedVariable ::= BlockTableEntry //{reject}
Item ::= ItemName
Item ::= ItemDereference
//%%TableName -> Table //%% AMBIGUOUS
Table ::= TableDereference //{reject}
//%% This is only used on right side of assignment statement
TableItemNoDeref ::= TableItemName
Subscript
OptTableDereference //{cons("TableItem")}
TableItem ::= TableItemName
OptSubscript
//%% OptTableDereference //%% Optional makes AMBIGUOUS with Name
TableDereference //{cons("TableItem")}
OptSubscript ::= Subscript
OptSubscript ::= /*% empty %*/ //{cons("no-subscript")}
OptTableDereference ::= TableDereference
OptTableDereference ::= /*% empty %*/ //{cons("no-table-dereference")}
TableEntry ::= TableName
Subscript //{cons("TableEntry"), reject} //%% Makes AMBIGUOUS with TableItem
TableEntry ::= TableDereference
Subscript //{cons("TableEntry"), reject} //%% Makes AMBIGUOUS with TableDereference
BlockItem ::= ItemName
OptBlockDereference //{cons("BlockItem"), reject} //%% AMBIGUOUS with BlockTable
BlockTable ::= TableName
BlockDereference //{cons("BlockTable")}
//%% OptBlockDereference -> BlockTable //%% Optional makes AMBIGUOUS with Name
BlockTableItem ::= TableItemName
OptSubscript
OptBlockDereference //{cons("BlockTableItem"), reject} //%% AMBIGUOUS with TableItem
BlockTableEntry ::= TableName
Subscript
OptBlockDereference //{cons("BlockTableEntry")}
OptBlockDereference ::= BlockDereference
OptBlockDereference ::= /*% empty %*/ //{cons("no-block-dereference")}
BlockDereference ::= Dereference //{reject}
ItemDereference ::= Dereference
TableDereference ::= Dereference //{prefer}
Dereference ::= '@' Name Subscript //{cons("TableDereference")}
Dereference ::= '@' PointerItemName //{cons("Dereference")}
Dereference ::= '@' '(' Formula ')' //{cons("Dereference")}
Dereference ::= '@' '(' PointerLiteral ')' //{cons("Dereference"), reject} //%% This prevents NULL from being dereferenced
PointerItemName ::= ItemName //{prefer}
PointerItemName ::= TableItemName
PointerItemName ::= ConstantItemName
Subscript ::= '(' //{ Index ','}+ ')' //{cons("Subscript")}
//%% Productions of Index generalized to Formula
//%% Grammar originally allows for IntegerFormula, StatusFormula
Index ::= Formula //{prefer}
BitFunctionVariable ::= 'BIT' '(' Variable ','
Fbit ',' Nbit ')' //{cons("BitFunctionVariable"), prefer}
//%% Added production of BitFunctionVariable with BitFormula inside
//%% to allow variables with parentheses to be used
BitFunctionVariable ::= 'BIT' '(' Formula ','
Fbit ',' Nbit ')' //{cons("BitFunctionVariable")}
//%%'BYTE'
//%% '(' CharacterVariable ','
//%% Fbyte ',' Nbyte ')' -> ByteFunctionVariable //{cons("ByteFunctionVariable")}
ByteFunctionVariable ::= 'BYTE' '(' Variable ','
Fbyte ',' Nbyte ')' //{cons("ByteFunctionVariable")}
RepFunctionVariable ::= RepConversion
'(' NamedVariable ')' //{cons("RepFunctionVariable")}
RepFunctionVariable ::= RepConversion
'(' NamedVariable Subscript ')' //{cons("RepFunctionVariable")}
BlockReference ::= BlockName
BlockReference ::= BlockDereference
BlockReference ::= BlockName
BlockDereference //{cons("BlockReference")}
ConstantItemName ::= Name
BlockName ::= Name
//%% 6.2 NAMED CONSTANTS
//%%
NamedConstant ::= ConstantItemName //{prefer} //%% ambiguous with ConstantTableName
NamedConstant ::= ConstantTableName //{cons("ConstantTableName")}
NamedConstant ::= ConstantTableItemName
OptSubscript //{cons("NamedConstant"), reject} //%% AMBIGUOUS with IntegerTerm
NamedConstant ::= ConstantTableName
Subscript //{cons("NamedConstant")}
NamedConstant ::= ControlLetter //{cons("ControlLetter")}
ConstantTableItemName ::= TableItemName
ConstantTableName ::= Name
//%% 6.3 FUNCTION CALLS
//%%
FunctionCall ::= IntrinsicFunctionCall //{prefer}
FunctionCall ::= MachineSpecificFunctionCall
FunctionCall ::= UserDefinedFunctionCall
//%% Removed Opt from ActualParameterList to distinguish from Variable.
//%% Now user-defined function calls must have parens. Resolution of function calls
//%% without parens will require name resolution using a symbol table.
UserDefinedFunctionCall ::= FunctionName
ActualParameterList //{cons("UserDefinedFunctionCall")}
IntrinsicFunctionCall ::= LocFunction
IntrinsicFunctionCall ::= NextFunction
IntrinsicFunctionCall ::= BitFunction
IntrinsicFunctionCall ::= ByteFunction
IntrinsicFunctionCall ::= ShiftFunction
IntrinsicFunctionCall ::= AbsFunction
IntrinsicFunctionCall ::= SignFunction
IntrinsicFunctionCall ::= SizeFunction
IntrinsicFunctionCall ::= BoundsFunction
IntrinsicFunctionCall ::= NwdsenFunction
IntrinsicFunctionCall ::= StatusInverseFunction
IntrinsicFunctionCall ::= NentFunction
MachineSpecificFunctionCall ::= FunctionName //%% AMBIGUOUS with NamedConstant
OptActualParameterList //{cons("MachineSpecificFunctionCall"), reject}
//%% 6.3.1 LOC FUNCTION
//%%
LocFunction ::= 'LOC' '(' LocArgument ')' //{cons("LocFunction")}
//%% Added because can't distinguish between the different names below
LocArgument ::= Name //{prefer}
//%% Added because TableItem is a NamedVariable
//%% but can only be accessed through UserDefinedFunctionCall
LocArgument ::= UserDefinedFunctionCall
LocArgument ::= NamedVariable
LocArgument ::= StatementName
LocArgument ::= ProcedureName
LocArgument ::= FunctionName
LocArgument ::= BlockReference
//%% 6.3.2 NEXT FUNCTION
//%%
NextFunction ::= 'NEXT' '('
NextArgument ','
IncrementAmount ')' //{cons("NextFunction")}
//%%Productions of NextArgument generalized to Formula
//%%Grammar originally allows for PointerFormula, StatusFormula
NextArgument ::= Formula
IncrementAmount ::= Formula
//%% 6.3.3 BIT FUNCTION
//%%
//%%Grammar originally allows BitFormula as first argument
BitFunction ::= 'BIT' '(' Formula
',' Fbit ',' Nbit ')' //{cons("BitFunction")}
BitFunction ::= 'BIT' '(' RepFunctionVariable
',' Fbit ',' Nbit ')' //{cons("BitFunction"), prefer}
Fbit ::= Formula //{cons("Fbit")}
Nbit ::= Formula //{cons("Nbit")}
//%% 6.3.4 BYTE FUNCTION
//%%
ByteFunction ::= 'BYTE' '(' Formula
',' Fbyte ',' Nbyte ')' //{cons("ByteFunction")}
Fbyte ::= Formula
Nbyte ::= Formula
//%% 6.3.5 SHIFT FUNCTIONS
//%%
ShiftFunction ::= ShiftDirection
'(' Formula ','
ShiftCount ')' //{cons("ShiftFunction")}
ShiftFunction ::= ShiftDirection
'(' RepFunctionVariable ','
ShiftCount ')' //{cons("ShiftFunction"), prefer}
ShiftDirection ::= 'SHIFTL' //{cons("SHIFTL")}
ShiftDirection ::= 'SHIFTR' //{cons("SHIFTR")}
ShiftCount ::= Formula
//%% 6.3.6 ABS FUNCTION
//%%
AbsFunction ::= 'ABS' '(' Formula ')' //{cons("AbsFunction")}
//%% 6.3.7 SIGN FUNCTION
//%%
SignFunction ::= 'SGN' '(' Formula ')' //{cons("SignFunction")}
//%% 6.3.7 SIZE FUNCTIONS
//%%
SizeFunction ::= SizeType
'(' SizeArgument ')' //{cons("SizeFunction")}
SizeType ::= 'BITSIZE' //{cons("BITSIZE")}
SizeType ::= 'BYTESIZE' //{cons("BYTESIZE")}
SizeType ::= 'WORDSIZE' //{cons("WORDSIZE")}
SizeArgument ::= Formula //{prefer}
SizeArgument ::= BlockName
SizeArgument ::= TypeName
//%% 6.3.9 BOUNDS FUNCTIONS
//%%
BoundsFunction ::= WhichBound
'(' BoundsArgument ','
DimensionNumber ')' //{cons("BoundsFunction")}
WhichBound ::= 'LBOUND' //{cons("LBOUND")}
WhichBound ::= 'UBOUND' //{cons("UBOUND")}
BoundsArgument ::= TableName //{cons("Name"), prefer}
BoundsArgument ::= TableTypeName
DimensionNumber ::= CompileTimeNumericFormula
//%% 6.3.10 NWDSEN FUNCTION
//%%
NwdsenFunction ::= 'NWDSEN'
'(' NwdsenArgument ')' //{cons("NwdsenFunction")}
NwdsenArgument ::= TableName //{cons("Name"), prefer}
NwdsenArgument ::= TableTypeName
//%% 6.3.11 STATUS INVERSE FUNCTIONS
//%%
StatusInverseFunction ::= 'FIRST' '('
StatusInverseArgument ')' //{cons("StatusInverseFunctionFIRST")}
StatusInverseFunction ::= 'LAST' '('
StatusInverseArgument ')' //{cons("StatusInverseFunctionLAST")}
//%%Grammar originially allows for StatusFormula as a StatusInverseArgument
StatusInverseArgument ::= Formula
StatusInverseArgument ::= StatusTypeName //{prefer}
//%% 6.3.12 NENT FUNCTION
//%%
NentFunction ::= 'NENT' '(' NentArgument ')' //{cons("NentFunction")}
NentArgument ::= TableName //{cons("Name"), prefer}
NentArgument ::= TableTypeName
//%%%%%%%%%%
//%% 7.0 TYPE MATCHING AND TYPE CONVERSIONS
//%%%%%%%%%%
BitConversion ::= BitTypeConversion
BitConversion ::= RepConversion //{reject} //%% fixes ambiguity, RepFunctionVariable and BitPrimaryConversion
BitTypeConversion ::= '(*'
BitTypeDescription
'*)' //{cons("BitTypeConversion")}
BitTypeConversion ::= BitTypeName //{reject} //%% reject to remove ambiguities, using UserDefinedFunctionCall for type name conversions
BitTypeConversion ::= 'B' //{cons("BitTypeConversionB")}
//%% '(*'
//%% IntegerTypeDescription
//%% '*)' -> IntegerConversion //{cons("IntegerConversion")}
//%% Replacing above with two productions of IntegerTypeDescription during IntegerConversion
//%% here to allow for distinction while traversing between conversions
//%% that are unambiguously IntegerConversion and conversions that are
//%% using IntegerTypeName to parse but could be other type conversions
IntegerConversion ::= '(*'
IntegerItemDescription
'*)' //{cons("IntegerConversion")}
IntegerConversion ::= '(*'
IntegerTypeName
'*)' //{cons("TypeNameConversion")}
IntegerConversion ::= IntegerTypeName //{reject} //%% reject to remove ambiguities, using UserDefinedFunctionCall for type name conversions
IntegerConversion ::= 'S' //{cons("IntegerConversionS")}
IntegerConversion ::= 'U' //{cons("IntegerConversionU")}
FloatingConversion ::= '(*'
FloatingTypeDescription
'*)' //{cons("FloatingConversion")}
FloatingConversion ::= FloatingTypeName //{reject} //%% reject to remove ambiguities, using UserDefinedFunctionCall for type name conversions
FloatingConversion ::= 'F' //{cons("FloatingConversionF")}
FixedConversion ::= '(*'
FixedTypeDescription
'*)' //{cons("FixedConversion")}
FixedConversion ::= FixedTypeName //{reject} //%% reject to remove ambiguities, using UserDefinedFunctionCall for type name conversions
CharacterConversion ::= '(*'
CharacterTypeDescription
'*)' //{cons("CharacterConversion")}
CharacterConversion ::= CharacterTypeName //{reject} //%% reject to remove ambiguities, using UserDefinedFunctionCall for type name conversions
CharacterConversion ::= 'C' //{cons("CharacterConversionC")}
//%% reject these to remove ambiguities, using UserDefinedFunctionCall for type name conversions
StatusConversion ::= '(*' StatusTypeName '*)' //{cons("StatusConversion"), reject}
StatusConversion ::= StatusTypeName //{reject}
PointerConversion ::= '(*'
PointerTypeDescription
'*)' //{cons("PointerConversion")}
PointerConversion ::= PointerTypeName //{reject} //%% reject to remove ambiguities, using UserDefinedFunctionCall for type name conversions
PointerConversion ::= 'P' //{cons("PointerConversionP")}
//%% reject these to remove ambiguities, using UserDefinedFunctionCall for type name conversions
TableConversion ::= '(*' TableTypeName '*)' //{cons("TableConversion"), reject}
TableConversion ::= TableTypeName //{reject}
RepConversion ::= 'REP' //{cons("RepConversion")}
//%%%%%%%%%%
//%% 8.0 BASIC ELEMENTS (see also, JovialLex.sdf)
//%%%%%%%%%%
//%% 8.1 CHARACTERS (see also, JovialLex.sdf)
//%%
Character ::= Letter
Character ::= Digit
Character ::= Mark
//%% OtherCharacter -> Character
//%% 8.2 SYMBOLS
//%%
Symbol ::= Name
Symbol ::= ReservedWord
Symbol ::= Operator
Symbol ::= Literal
Symbol ::= StatusConstant
//%% Comment -> Symbol //%% Moved to JovialLex.sdf
Symbol ::= DefineString
Symbol ::= DefineCall
Symbol ::= Letter
//%% Separator -> Symbol
//%% 8.2.1 NAMES (see JovialLex.sdf)
//%%
//%% 8.2.3 OPERATORS
//%%
Operator ::= ArithmeticOperator
Operator ::= BitOperator
Operator ::= RelationalOperator
Operator ::= DereferenceOperator
Operator ::= AssignmentOperator
ArithmeticOperator ::= PlusOrMinus
ArithmeticOperator ::= MultiplyDivideOrMod
ArithmeticOperator ::= MultiplyOrDivide
ArithmeticOperator ::= '**' //{cons("PowerOp")}
PlusOrMinus ::= '+' //{cons("AddOp")}
PlusOrMinus ::= '-' //{cons("SubtractOp")}
MultiplyDivideOrMod ::= '*' //{cons("MultiplyOp")}
MultiplyDivideOrMod ::= '/' //{cons("DivideOp")}
MultiplyDivideOrMod ::= MODOperator //{cons("ModOp")}
MultiplyOrDivide ::= '*' //{cons("MultiplyOp")}
MultiplyOrDivide ::= '/' //{cons("DivideOp")}
//%% Cons for NOT, AND, OR, XOR, EQV, DerefOp, and AssignOp will not be produced
BitOperator ::= LogicalOperator
BitOperator ::= 'NOT' //{cons("NOT")}
LogicalOperator ::= 'AND' //{cons("AND")}
LogicalOperator ::= 'OR' //{cons("OR")}
LogicalOperator ::= 'XOR' //{cons("XOR")}
LogicalOperator ::= 'EQV' //{cons("EQV")}
RelationalOperator ::= EqualOrNotEqualOperator
RelationalOperator ::= '<' //{cons("LessThanOp")}
//%%'>' -> RelationalOperator //{cons("GreaterThanOp")}
RelationalOperator ::= '<=' //{cons("LessOrEqualOp")}
RelationalOperator ::= '>=' //{cons("GreaterOrEqualOp")}
EqualOrNotEqualOperator ::= '=' //{cons("EqualityOp")}
EqualOrNotEqualOperator ::= '<>' //{cons("NotEqualOp")}
DereferenceOperator ::= '@' //{cons("DerefOp")}
AssignmentOperator ::= '=' //{cons("AssignOp")}
//%% 8.2.4 SEPARATORS
//%%
//%% TODO - see if constructors are needed for these
//%%
//%% 8.3 LITERALS
//%%
Literal ::= NumericLiteral
Literal ::= BitLiteral
Literal ::= BooleanLiteral
Literal ::= CharacterLiteral
Literal ::= PointerLiteral
//%% 8.3.1 NUMERIC LITERALS
//%%
NumericLiteral ::= IntegerLiteral
NumericLiteral ::= FloatingLiteral
NumericLiteral ::= FixedLiteral //{prefer} //%% added to remove ambiguity with FloatingLiteral
IntegerLiteral ::= Number //{cons("IntVal")}
Number ::= Icon
FloatingLiteral ::= RealLiteral
RealLiteral ::= Icon Exponent //{cons("RealLiteralIE")}
RealLiteral ::= FractionalForm OptExponent //{cons("RealLiteralFF")}
Exponent ::= 'E' OptSign Number //{cons("Exponent")}
Sign ::= '+' //{cons("PLUS")}
Sign ::= '-' //{cons("MINUS")}
//%% Unary signs now dealt with in Level2Expr as "UnaryPlus" and "UnaryMinus"
//%% OptSign is retained for the production of RealLiteral
OptSign ::= Sign
OptSign ::= /*% empty %*/ //{cons("no-sign")}
FractionalForm ::= OptNumber '.' OptNumber //{cons("FractionalForm")}
FixedLiteral ::= RealLiteral
OptExponent ::= Exponent
OptExponent ::= /*% empty %*/ //{cons("no-exponent")}
OptNumber ::= Number
OptNumber ::= /*% empty %*/ //{cons("no-number")}
//%% 8.3.2 BIT LITERALS
//%%
BitLiteral ::= BeadSize 'B' "'" Bead+ "'" //{cons("BitLiteral")}
Bead ::= Digit
//%% 8.3.3 BOOLEAN LITERALS
//%%
BooleanLiteral ::= 'TRUE' //{cons("True")}
BooleanLiteral ::= 'FALSE' //{cons("False")}
//%% 8.3.3 CHARACTER LITERALS
//%%
//%% CharString moved to JovialLex.sdf
CharacterLiteral ::= CharString //{cons("CharacterLiteral")}
//%% 8.3.4 POINTER LITERALS
//%%
PointerLiteral ::= 'NULL' //{cons("Null")}
//%% Comment moved to JovialLex.sdf
//%% '"' Character* '"' -> Comment //{cons("Comment")}
//%% '%' Character* '%' -> Comment //{cons("Comment")}
//%%%%%%%%%%
//%% 9.0 DIRECTIVES
//%%%%%%%%%%
Directive ::= CompoolDirective
Directive ::= CopyDirective
Directive ::= SkipDirective
Directive ::= BeginDirective
Directive ::= EndDirective
Directive ::= TraceDirective
Directive ::= InterferenceDirective
Directive ::= NolistDirective
Directive ::= ListDirective
Directive ::= EjectDirective
Directive ::= ListinvDirective
Directive ::= ListexpDirective
Directive ::= ListbothDirective
Directive ::= BaseDirective
Directive ::= IsbaseDirective
Directive ::= DropDirective
Directive ::= LeftrightDirective
Directive ::= RearrangeDirective
Directive ::= InitializeDirective
Directive ::= OrderDirective
PostProcDirective ::= LinkageDirective //%% only after ProcedureHeading
PostProcDirective ::= ReducibleDirective //%% only after FunctionHeading (but SEA compiler is flexible)
//%% 9.1 COMPOOL DIRECTIVE
//%%
CompoolDirective ::= '!COMPOOL'
CompoolDirectiveList ';' //{cons("CompoolDirective")}
CompoolDirectiveList ::= OptCompoolFileName
//{CompoolDeclaredName ','}+ //{cons("CompoolDirectiveList")}
CompoolDirectiveList ::= '(' OptCompoolFileName ')' //{cons("CompoolDirectiveList")}
CompoolDeclaredName ::= Name //{cons("Name")}
CompoolDeclaredName ::= '(' Name ')' //{cons("Name")}
CompoolFileName ::= CharacterLiteral
OptCompoolFileName ::= CompoolFileName
OptCompoolFileName ::= /*% empty %*/ //{cons("no-compool-file-name")}
//%% 9.2 TEXT DIRECTIVES
//%%
//%% 9.2.1 COPY DIRECTIVES
//%%
CopyDirective ::= '!COPY' CharacterLiteral ';' //{cons("CopyDirective")}
//%% 9.2.2 SKIP, BEGIN, AND END DIRECTIVES
//%%
SkipDirective ::= '!SKIP' OptLetter ';' //{cons("SkipDirective")}
BeginDirective ::= '!BEGIN' OptLetter ';' //{cons("BeginDirective")}
EndDirective ::= '!END' ';' //{cons("EndDirective")}
OptLetter ::= Letter
OptLetter ::= /*% empty %*/ //{cons("no-letter")}
//%% 9.3 LINKAGES DIRECTIVES
//%%
LinkageDirective ::= '!LINKAGE' Symbol+ ';' //{cons("LinkageDirective")}
//%% 9.4 TRACE DIRECTIVES
//%%
TraceDirective ::= '!TRACE' OptTraceControl
//{Name ','}+ ';' //{cons("TraceDirective")}
TraceControl ::= '(' BooleanFormula ')' //{cons("TraceControl")}
OptTraceControl ::= TraceControl
OptTraceControl ::= /*% empty %*/ //{cons("no-trace-control")}
//%% 9.5 INTERFERENCE DIRECTIVES
//%%
InterferenceDirective ::= '!INTERFERENCE'
InterferenceControl ';' //{cons("InterferenceDirective")}
InterferenceControl ::= DataName ':' //{DataName ','}+ //{cons("InterferenceControl")}
DataName ::= Name
//%% 9.6 REDUCIBLE DIRECTIVES
//%%
ReducibleDirective ::= '!REDUCIBLE' ';' //{cons("ReducibleDirective")}
//%% 9.7 LISTING DIRECTIVES
//%%
//%% 9.7.1 SOURCE-LISTING DIRECTIVES
//%%
NolistDirective ::= '!NOLIST' ';' //{cons("NolistDirective")}
ListDirective ::= '!LIST' ';' //{cons(" ListDirective")}
EjectDirective ::= '!EJECT' ';' //{cons(" EjectDirective")}
//%% 9.7.2 DEFINE-LISTING DIRECTIVES
//%%
ListinvDirective ::= '!LISTINV' ';' //{cons("ListinvDirective")}
ListexpDirective ::= '!LISTEXP' ';' //{cons("ListexpDirective")}
ListbothDirective ::= '!LISTBOTH' ';' //{cons("ListbothDirective")}
//%% 9.8 REGISTER DIRECTIVES
//%%
BaseDirective ::= '!BASE' DataName
IntegerLiteral ';' //{cons("BaseDirective")}
IsbaseDirective ::= '!ISBASE' DataName
IntegerLiteral ';' //{cons("IsbaseDirective")}
DropDirective ::= '!DROP'
IntegerLiteral ';' //{cons("DropDirective")}
//%% 9.9 EXPRESSION EVALUATION ORDER DIRECTIVES
//%%
LeftrightDirective ::= '!LEFTRIGHT' ';' //{cons("LeftrightDirective")}
RearrangeDirective ::= '!REARRANGE' ';' //{cons("RearrangeDirective")}
//%% 9.10 INITIALIZATION DIRECTIVES
//%%
InitializeDirective ::= '!INITIALIZE' ';' //{cons("InitializeDirective")}
//%% 9.11 ALLOCATION ORDER DIRECTIVES
//%%
OrderDirective ::= '!ORDER' ';' //{cons("OrderDirective")}
And here is the EBNF
for https://github.com/rose-compiler/rose/blob/weekly/src/3rdPartyLibraries/POET/poet_yacc.y
/* converted on Mon Nov 14, 2022, 14:41 (UTC+01) by bison-to-w3c v0.62 which is Copyright (c) 2011-2022 by Gunther Rademacher <grd@gmx.net> */
poet ::= section*
section ::= LTAG ( ( PARAMETER ID paramAttr* | DEFINE ID parseType | ( EVAL | COND ) code | TRACE ID ( COMMA ID )* ( ASSIGN codeUnit )? | OUTPUT outputAttr* ) ENDTAG | CODE ID codeAttr* codeRHS | INPUT inputAttr* inputRHS | XFORM ID xformAttr* xformRHS )
| inputBase INPUT_ENDFILE
inputAttr
::= ( DEBUG | SYNTAX | FROM | ANNOT | COND ) ASSIGN codeUnit
| TO ASSIGN ( POETTYPE | ID )
| PARSE ASSIGN ( POETTYPE | parseType )
outputAttr
::= ( FROM | SYNTAX | TO | COND ) ASSIGN codeUnit
inputRHS ::= RTAG inputBase ENDINPUT
| ENDTAG
codeAttr ::= PARS ASSIGN LP codePars RP
| ( ID | COND | REBUILD | OUTPUT ) ASSIGN codeUnit
| PARSE ASSIGN parseType
| LOOKAHEAD ASSIGN ICONST
| MATCH ASSIGN matchSpec
matchSpec
::= varInvoke
| PARSE
varRef ::= ( GLOBAL DOT )? ID
| XFORM xformRef
| CODE codeRef
xformRef ::= ( DOT ID )?
codeRef ::= ( DOT ID )?
codePars ::= ID ( COLON parseType )?
| codePars COMMA codePars
paramAttr
::= TYPE ASSIGN typeMulti
| DEFAULT ASSIGN codeUnit
| PARSE ASSIGN parseType
| MESSAGE ASSIGN SOURCE
map ::= MAP ( LP ( typeSpec COMMA typeSpec )? RP | LB ( codeUnit ARROW codeUnit ( COMMA codeUnit ARROW codeUnit )* )? RB )?
singletype
::= constant
| ANY
| INT
| FLOAT
| STRING
| NAME
| EXP
| VAR
| TUPLE
| map
typeSpec1
::= ( ID ASSIGN )* ( singletype | MINUS ICONST | ( EVAL LP code | LP typeMulti ) RP | varInvokeType | TILT typeSpec )
typeSpec ::= typeSpec1
| typeSpec TOR typeSpec
typeMulti
::= typeSpec ( typeSpec* | ( COMMA typeSpec )+ | DOT4 | DOT3 | ( PLUS | MULTIPLY | DIVIDE | MOD | DCOLON ) typeSpec )
| typeSpec1 DOT2 typeSpec1
patternSpec
::= singletype
| MINUS ICONST
| CLEAR ID
| varInvokePattern
| LP patternMulti RP
| patternSpec ( ( TOR | DOT2 | PLUS | MULTIPLY | DIVIDE | MOD | DCOLON ) patternSpec | DOT3 )
| ID ASSIGN patternSpec
patternMulti
::= patternSpec ( patternSpec* | ( COMMA patternSpec )+ )
constant ::= ICONST
| FCONST
| SOURCE
| ENDLIST
parseType1
::= ( TUPLE LP parseElem parseElemList | ( LIST | LIST1 ) LP parseElem COMMA constantOrVar ) RP
parseType
::= parseType1
| typeSpec1
| parseType ( TOR parseType | DOT4 | DOT3 )
parseElem
::= singletype
| varInvokeType
| TILT typeSpec
| parseType1
| ( ID ASSIGN | parseElem TOR ) parseElem
| LP parseElemMulti RP
parseElemMulti
::= parseElem ( parseElemList | ( COMMA parseElem )+ )
parseElemList
::= parseElem*
constantOrVar
::= constant
| varRef
codeRHS ::= RTAG code ENDCODE
| ENDTAG
xformRHS ::= ( RTAG code )? ENDXFORM
xformAttr
::= ( PARS ASSIGN LP xformPars | OUTPUT ASSIGN LP outputPar ( COMMA outputPar )* ) RP
| ID ASSIGN typeSpec
xformPars
::= ID ( COLON typeSpec )?
| xformPars COMMA xformPars
outputPar
::= ID ( COLON typeSpec )?
code ::= codeIf* ( codeIf | code23 )
codeIf ::= IF LP code4 RP code1 codeIfHelp
| code1
codeIfHelp
::= ( ELSE codeIf )?
code1 ::= ( ( FOR LP e_code4 SEMICOLON e_code4 SEMICOLON e_code4 | ( FOREACH | FOREACH_R ) LP code6 COLON patternSpec COLON code4 ) RP )* ( ( SWITCH LP code RP LB CASE patternSpec COLON code ( ( CASE patternSpec | DEFAULT ) COLON code )* | LB code? ) RB | FOREACH patternAssign IN foreach_body suchThat DO code ENDDO | code3? SEMICOLON )
foreach_body
::= code6
| REVERSE LP code6 RP
e_code4 ::= code4?
patternAssign
::= ID ASSIGN patternSpec
| varInvokePattern
suchThat ::= ( SUCH_THAT code4 )?
code23 ::= code3 ( COMMA code3 )*
code3 ::= CONTINUE
| BREAK
| RETURN? code4
| ( ERROR | ASSERT | PRINT ) codeUnit
code4 ::= ( code8 ASSIGN | code5 QUESTION code6 COLON )* ( code5 | code8 ( ( ARROW | DARROW ) parseElem | ( PLUS_ASSIGN | MINUS_ASSIGN | MULT_ASSIGN | DIVIDE_ASSIGN | MOD_ASSIGN ) code5 ) )
code5 ::= code5 ( AND | OR ) code5
| NOT code6
| code6 ( ( LT | LE | EQ | GT | GE | NE ) code6 | COLON patternSpec )?
code6 ::= code7
| ( code6 ( PLUS | MINUS | MULTIPLY | STR_CONCAT | DIVIDE | MOD | DCOLON ) | MINUS ) code6
code7 ::= code8 code7Help
code7Help
::= code8*
code8 ::= ( REPLACE LP code5 COMMA | TRACE LP ) code5 paramRHS
| ( ( ( PERMUTE | INSERT | SPLIT ) LP | DUPLICATE LP code5 COMMA ) code5 COMMA code5 | RANGE LP codeUnit COMMA codeUnit ) RP
| ( COPY | REBUILD | RESTORE | SAVE ) codeUnit
| ERASE LP code5 eraseRHS
| ( DELAY | DEBUG debugConfig | APPLY ) LB code RB
| codeUnit ( DOT3 | DOT2 codeUnit )
| code9
paramRHS ::= ( COMMA code5 )? RP
eraseRHS ::= ( COMMA code5 )? RP
debugConfig
::= ( LBR ICONST RBR )?
inputBase
::= ( INPUT_ENDL | ARROW parseElem | ( LBEGIN | RBEGIN ) LP parseElem RP | ICONST | FCONST | SOURCE | INPUT_CONT | ID )*
code9 ::= ( CAR | CDR | LEN | INT | CLEAR ) codeUnit
| varInvoke
codeUnit ::= LP code? RP
| constant
| ANY
| varRef
| map
varInvoke
::= codeUnit ( LBR configOrSubRef RBR )* pond?
| varInvoke TOR varInvoke
pond ::= POND codeUnit
varInvokeType
::= varRef varInvokeType1
varInvokeType1
::= ( LBR configRef RBR | POND typeSpec )?
varInvokePattern
::= varRef varInvokePattern1
varInvokePattern1
::= ( LBR xformConfig RBR | POND patternSpec )?
configOrSubRef
::= code5
| configRef
| selectRef
selectRef
::= selectRef TOR selectRef
| ID DOT ID
configRef
::= ID ASSIGN code5
| configRef SEMICOLON configRef
xformConfig
::= ID ASSIGN typeSpec
| xformConfig SEMICOLON xformConfig
//
//Tokens
//
//\("[^"]+"\)\s+{.+?return \(\S[^;]+\); } -> \2 ::= \1
ENDLIST ::= "NULL"
IN ::= "\\in"
SUCH_THAT ::= "s.t."
DO ::= "do"
ENDDO ::= "enddo"
ERROR ::= "ERROR"
REVERSE ::= "reverse"
PERMUTE ::= "PERMUTE"
REPLACE ::= "REPLACE"
ASSERT ::= "assert"
RANGE ::= "RANGE"
INSERT ::= "INSERT"
MAP ::= "MAP"
XFORM ::= "XFORM"
EVAL ::= "eval"
CODE ::= "CODE"
GLOBAL ::= "GLOBAL"
REBUILD ::= "REBUILD"
DELAY ::= "DELAY"
APPLY ::= "APPLY"
PRINT ::= "PRINT"|"print"
SAVE ::= "SAVE"
RESTORE ::= "RESTORE"
VAR ::= "VAR"
TRACE ::= "TRACE"
ERASE ::= "ERASE"
COPY ::= "COPY"
CLEAR ::= "CLEAR"
DUPLICATE ::= "DUPLICATE"
SPLIT ::= "SPLIT"
LEN ::= "LEN"
INT ::= "INT"
FLOAT ::= "FLOAT"
STRING ::= "STRING"
NAME ::= "ID"
EXP ::= "EXP"
TUPLE ::= "TUPLE"
LIST ::= "LIST"
LIST1 ::= "LIST1"
SOURCE ::= "ENDL"
CASE ::= "case"
DEFAULT ::= "default"
SWITCH ::= "switch"
BREAK ::= "BREAK"|"break"
CONTINUE ::= "CONTINUE"|"continue"
RETURN ::= "RETURN"|"return"
DEBUG ::= "DEBUG"
FOR ::= "for"
FOREACH ::= "foreach"
FOREACH_R ::= "foreach_r"
IF ::= "if"
ELSE ::= "else"
CAR ::= "car"
CDR ::= "cdr"
CAR ::= "HEAD"
CDR ::= "TAIL"
ICONST ::= "TRUE"
ICONST ::= "FALSE"
ANY ::= "_"
POND ::= "#"
LB ::= "{"
RB ::= "}"
LP ::= "("
LBR ::= "["
RP ::= ")"
RBR ::= "]"
AND ::= "&&"
OR ::= "||"
TOR ::= "|"
NOT ::= "!"
GE ::= ">="
QUESTION ::= "?"
GT ::= ">"
LE ::= "<="
LT ::= "<"
DARROW ::= "==>"
ARROW ::= "=>"
EQ ::= "=="
ASSIGN ::= "="
NE ::= "!="
COMMA ::= ","
SEMICOLON ::= ";"
PLUS_ASSIGN ::= "+="
MINUS_ASSIGN ::= "-="
MULT_ASSIGN ::= "*="
MOD_ASSIGN ::= "%="
DIVIDE_ASSIGN ::= "/="
STR_CONCAT ::= "^"
PLUS ::= "+"
MINUS ::= "-"
MULTIPLY ::= "*"
MOD ::= "%"
DIVIDE ::= "/"
DCOLON ::= "::"
COLON ::= ":"
DOT3 ::= "..."
DOT4 ::= "...."
DOT2 ::= ".."
DOT ::= "."
TILT ::= "~"
//<[^>]+>\("[^"]+"\)\s+{.+?return\s+\(\S[^;]+\);\s+} -> \2 ::= \1
LTAG ::= "<"
//<INITIAL>({linebreak}|{space}) { CHECK_INPUT; }
//<INITIAL>{id} { CHECK_INPUT; RETURN_SOURCE; }
//<INITIAL>{integer} { CHECK_INPUT; yylval.ptr = make_Iconst(yytext,yyleng); return ICONST; }
//<INITIAL>{float} { CHECK_INPUT; yylval.ptr = make_sourceString(yytext,yyleng); return FCONST; }
//<INITIAL>. { CHECK_INPUT; RETURN_SOURCE; }
DEFINE ::= "define"
EVAL ::= "eval"
COND ::= "cond"
TRACE ::= "trace"
PARAMETER ::= "parameter"
OUTPUT ::= "output"
XFORM ::= "xform"
CODE ::= "code"
INPUT ::= "input"
ENDTAG ::= "/>"
SYNTAX ::= "syntax"
POETTYPE ::= "POET"
TO ::= "to"
FROM ::= "from"
DEBUG ::= "debug"
TYPE ::= "type"
ANNOT ::= "annot"
COND ::= "cond"
MESSAGE ::= "message"
PARS ::= "pars"
REBUILD ::= "rebuild"
PARSE ::= "parse"
LOOKAHEAD ::= "lookahead"
MATCH ::= "match"
OUTPUT ::= "output"
LBEGIN ::= "BEGIN"
RBEGIN ::= "BEGIN"
//<IN_IARG>";" { BEGIN(IN_IARG_R); }
//<IN_IARG1>";" { BEGIN(IN_IARG1_R); }
//<IN_CODE_TAG>">"[\t ]*{linebreak}?([\t ]*@@)? { BEGIN(IN_CODE); lexState=LEX_INPUT; return RTAG; }
RTAG ::= ">"
ENDXFORM ::= "/>"
//<IN_CODE,IN_INPUT,IN_INPUT_NOANNOT>{id} { yylval.ptr = make_sourceString(yytext, yyleng); return SOURCE; }
//<IN_CODE,IN_INPUT,IN_INPUT_NOANNOT>{integer} { yylval.ptr = make_Iconst(yytext,yyleng); return ICONST; }
//<IN_CODE,IN_INPUT,IN_INPUT_NOANNOT>{float} { yylval.ptr = make_sourceString(yytext, yyleng); return FCONST; }
ENDCODE ::= "</code>" //<IN_CODE>{linebreak}?{space}*"</code>" { BEGIN(0); lexState=LEX_DEFAULT; return ENDCODE; }
//<IN_CODE>{linebreak}({space}*"@@")? { yylval.ptr = make_sourceString(yytext,1); return SOURCE; }
//<IN_CODE>"@"|("@"{linebreak}) { BEGIN(IN_ARG); lexState=LEX_DEFAULT; }
//<IN_ARG>"@" { BEGIN(IN_CODE); lexState=LEX_INPUT; }
//<IN_INPUT_TAG>">"[\t ]* { BEGIN(IN_IARG1); return RTAG; }
//<IN_INPUT>[\t ]*"</input>" { BEGIN(0); lexState=LEX_DEFAULT; return ENDINPUT; }
//<IN_INPUT>{space}*"//@</input>" { BEGIN(0); lexState=LEX_DEFAULT; return ENDINPUT; }
//<IN_INPUT>([\t ]*"/*@") { BEGIN(IN_IARG); lexState=LEX_DEFAULT; }
//<IN_INPUT>([\t ]*"//@") { BEGIN(IN_IARG1); lexState=LEX_DEFAULT; }
//<IN_INPUT,IN_INPUT_NOANNOT><<EOF>> { BEGIN(0); lexState=LEX_DEFAULT; return INPUT_ENDFILE;}
//<IN_INPUT,IN_INPUT_NOANNOT>(\\\n) { yylval.ptr=make_sourceString("\\\n",2); return INPUT_CONT;}
//<IN_INPUT,IN_INPUT_NOANNOT>{linebreak} { yylval.ptr=make_sourceString("\n", 1); return INPUT_ENDL;}
//<IN_CODE,IN_INPUT,IN_INPUT_NOANNOT>. { yylval.ptr = make_sourceString(yytext, yyleng); return SOURCE; }
ENDINPUT ::= "</input>"
//<IN_IARG,IN_IARG_R>("@") { BEGIN(IN_INPUT); lexState=LEX_INPUT; }
//<IN_IARG,IN_IARG_R>("@*/")[ \t]* { BEGIN(IN_INPUT); lexState=LEX_INPUT; }
//<IN_IARG1,IN_IARG1_R>{linebreak} { BEGIN(IN_INPUT); lexState=LEX_INPUT; yylval.ptr = make_sourceString("\n", 1); return INPUT_ENDL; }
ENDXFORM ::= "</xform>"
//<IN_XFORM_TAG>-?{integer} { yylval.ptr = make_Iconst(yytext,yyleng); return ICONST; }
//<IN_CODE_TAG,IN_INPUT_TAG,IN_TAG,IN_EVAL_TAG,IN_TAG_BODY,IN_XFORM_TAG,IN_XFORM,IN_ARG,IN_IARG,IN_IARG_R,IN_IARG_PARSE,IN_OUTPUT_TAG>{linebreak}+ {}
And here is the EBNF
for https://github.com/rose-compiler/rose/blob/weekly/src/frontend/SageIII/ompparser.yy
/* converted on Mon Nov 14, 2022, 15:20 (UTC+01) by bison-to-w3c v0.62 which is Copyright (c) 2011-2022 by Gunther Rademacher <grd@gmx.net> */
openmp_directive
::= parallel_directive
| for_directive
| for_simd_directive
| declare_simd_directive
| sections_directive
| single_directive
| parallel_for_directive
| parallel_for_simd_directive
| parallel_sections_directive
| task_directive
| master_directive
| critical_directive
| atomic_directive
| ordered_directive
| barrier_directive
| taskwait_directive
| flush_directive
| threadprivate_directive
| section_directive
| target_directive
| target_data_directive
| simd_directive
parallel_directive
::= OMP PARALLEL parallel_clause_optseq
parallel_clause_optseq
::= ( parallel_clause ( ','? parallel_clause )* )?
proc_bind_clause
::= PROC_BIND '(' ( MASTER | CLOSE | SPREAD ) ')'
parallel_clause
::= if_clause
| num_threads_clause
| default_clause
| private_clause
| firstprivate_clause
| share_clause
| copyin_clause
| reduction_clause
| proc_bind_clause
copyin_clause
::= COPYIN '(' variable_list ')'
for_directive
::= OMP FOR for_clause_optseq
for_clause_optseq
::= ( for_clause ( ','? for_clause )* )?
for_clause
::= private_clause
| firstprivate_clause
| lastprivate_clause
| linear_clause
| reduction_clause
| schedule_clause
| collapse_clause
| ordered_clause
| nowait_clause
for_or_simd_clause
::= ordered_clause
| schedule_clause
| private_clause
| firstprivate_clause
| lastprivate_clause
| reduction_clause
| collapse_clause
| unique_simd_clause
| nowait_clause
schedule_chunk_opt
::= ( ',' expression )?
ordered_clause
::= ORDERED ordered_parameter_opt
ordered_parameter_opt
::= ( '(' expression ')' )?
schedule_clause
::= SCHEDULE '(' schedule_kind schedule_chunk_opt ')'
collapse_clause
::= COLLAPSE '(' expression ')'
schedule_kind
::= STATIC
| DYNAMIC
| GUIDED
| AUTO
| RUNTIME
sections_directive
::= OMP SECTIONS sections_clause_optseq
sections_clause_optseq
::= ( sections_clause ( ','? sections_clause )* )?
sections_clause
::= private_clause
| firstprivate_clause
| lastprivate_clause
| reduction_clause
| nowait_clause
section_directive
::= OMP SECTION
single_directive
::= OMP SINGLE single_clause_optseq
single_clause_optseq
::= ( single_clause ( ','? single_clause )* )?
nowait_clause
::= NOWAIT
single_clause
::= unique_single_clause
| private_clause
| firstprivate_clause
| nowait_clause
unique_single_clause
::= COPYPRIVATE '(' variable_list ')'
task_directive
::= OMP TASK task_clause_optseq
task_clause_optseq
::= ( task_clause ( ','? task_clause )* )?
task_clause
::= unique_task_clause
| default_clause
| private_clause
| firstprivate_clause
| share_clause
| depend_clause
| if_clause
unique_task_clause
::= ( FINAL | PRIORITY ) '(' expression ')'
| UNTIED
| MERGEABLE
depend_clause
::= DEPEND '(' dependence_type ':' postfix_expr ( ',' postfix_expr )* ')'
dependence_type
::= IN
| OUT
| INOUT
parallel_for_directive
::= OMP PARALLEL FOR parallel_for_clauseoptseq
parallel_for_clauseoptseq
::= ( parallel_for_clause ( ','? parallel_for_clause )* )?
parallel_for_clause
::= if_clause
| num_threads_clause
| default_clause
| private_clause
| firstprivate_clause
| share_clause
| copyin_clause
| reduction_clause
| proc_bind_clause
| lastprivate_clause
| linear_clause
| schedule_clause
| collapse_clause
| ordered_clause
parallel_for_simd_directive
::= OMP PARALLEL FOR SIMD parallel_for_simd_clauseoptseq
parallel_for_simd_clauseoptseq
::= ( parallel_for_simd_clause ( ','? parallel_for_simd_clause )* )?
parallel_for_simd_clause
::= copyin_clause
| ordered_clause
| schedule_clause
| unique_simd_clause
| default_clause
| private_clause
| firstprivate_clause
| lastprivate_clause
| reduction_clause
| collapse_clause
| share_clause
| if_clause
| num_threads_clause
| proc_bind_clause
parallel_sections_directive
::= OMP PARALLEL SECTIONS parallel_sections_clause_optseq
parallel_sections_clause_optseq
::= ( parallel_sections_clause ( ','? parallel_sections_clause )* )?
parallel_sections_clause
::= copyin_clause
| default_clause
| private_clause
| firstprivate_clause
| lastprivate_clause
| share_clause
| reduction_clause
| if_clause
| num_threads_clause
| proc_bind_clause
master_directive
::= OMP MASTER
critical_directive
::= OMP CRITICAL region_phraseopt
region_phraseopt
::= region_phrase?
region_phrase
::= '(' ID_EXPRESSION ')'
barrier_directive
::= OMP BARRIER
taskwait_directive
::= OMP TASKWAIT
atomic_directive
::= OMP ATOMIC atomic_clauseopt
atomic_clauseopt
::= atomic_clause?
atomic_clause
::= READ
| WRITE
| UPDATE
| CAPTURE
flush_directive
::= OMP FLUSH flush_varsopt
flush_varsopt
::= flush_vars?
flush_vars
::= '(' variable_list ')'
ordered_directive
::= OMP ORDERED
threadprivate_directive
::= OMP THREADPRIVATE '(' variable_list ')'
default_clause
::= DEFAULT '(' ( SHARED | NONE ) ')'
private_clause
::= PRIVATE '(' variable_list ')'
firstprivate_clause
::= FIRSTPRIVATE '(' variable_list ')'
lastprivate_clause
::= LASTPRIVATE '(' variable_list ')'
share_clause
::= SHARED '(' variable_list ')'
reduction_clause
::= REDUCTION '(' reduction_operator ':' variable_list ')'
reduction_operator
::= '+'
| '*'
| '-'
| MIN
| MAX
| '&'
| '^'
| '|'
| LOGAND
| LOGOR
target_data_directive
::= OMP TARGET DATA target_data_clause ( ','? target_data_clause )*
target_data_clause
::= device_clause
| map_clause
| if_clause
target_directive
::= OMP TARGET target_clause_optseq
target_clause_optseq
::= ( target_clause ( ','? target_clause )* )?
target_clause
::= device_clause
| map_clause
| if_clause
| num_threads_clause
| begin_clause
| end_clause
device_clause
::= DEVICE '(' expression_or_star_or_mpi
expression_or_star_or_mpi
::= ( MPI | MPI_ALL | MPI_MASTER | expression | '*' ) ')'
begin_clause
::= TARGET_BEGIN
end_clause
::= TARGET_END
if_clause
::= IF '(' expression ')'
num_threads_clause
::= NUM_THREADS '(' expression ')'
map_clause
::= MAP '(' map_clause_optseq id_expression_opt_dimension ( ',' id_expression_opt_dimension )* ')'
map_clause_optseq
::= ( ( ALLOC | TO | FROM | TOFROM ) ':' )?
for_simd_directive
::= OMP FOR SIMD for_or_simd_clause_optseq
for_or_simd_clause_optseq
::= ( for_or_simd_clause ( ','? for_or_simd_clause )* )?
simd_directive
::= OMP SIMD simd_clause_optseq
simd_clause_optseq
::= ( simd_clause ( ','? simd_clause )* )?
simd_clause
::= safelen_clause
| simdlen_clause
| linear_clause
| aligned_clause
| private_clause
| lastprivate_clause
| reduction_clause
| collapse_clause
safelen_clause
::= SAFELEN '(' expression ')'
unique_simd_clause
::= safelen_clause
| simdlen_clause
| aligned_clause
| linear_clause
simdlen_clause
::= SIMDLEN '(' expression ')'
declare_simd_directive
::= OMP DECLARE SIMD declare_simd_clause_optseq
declare_simd_clause_optseq
::= ( declare_simd_clause ( ','? declare_simd_clause )* )?
declare_simd_clause
::= simdlen_clause
| linear_clause
| aligned_clause
| uniform_clause
| INBRANCH
| NOTINBRANCH
uniform_clause
::= UNIFORM '(' variable_list ')'
aligned_clause
::= ALIGNED '(' variable_list aligned_clause_optseq ')'
aligned_clause_optseq
::= aligned_clause_alignment?
aligned_clause_alignment
::= ':' expression
linear_clause
::= LINEAR '(' variable_list linear_clause_step_optseq ')'
linear_clause_step_optseq
::= linear_clause_step?
linear_clause_step
::= ':' expression
expression
::= assignment_expr
assignment_expr
::= ( unary_expr ( '=' | RIGHT_ASSIGN2 | LEFT_ASSIGN2 | ADD_ASSIGN2 | SUB_ASSIGN2 | MUL_ASSIGN2 | DIV_ASSIGN2 | MOD_ASSIGN2 | AND_ASSIGN2 | XOR_ASSIGN2 | OR_ASSIGN2 ) )* ( conditional_expr | logical_or_expr )
conditional_expr
::= logical_or_expr '?' assignment_expr ':' assignment_expr
logical_or_expr
::= logical_and_expr ( LOGOR logical_and_expr )*
logical_and_expr
::= inclusive_or_expr ( LOGAND inclusive_or_expr )*
inclusive_or_expr
::= exclusive_or_expr ( '|' exclusive_or_expr )*
exclusive_or_expr
::= and_expr ( '^' and_expr )*
and_expr ::= equality_expr ( '&' equality_expr )*
equality_expr
::= relational_expr ( ( EQ_OP2 | NE_OP2 ) relational_expr )*
relational_expr
::= shift_expr ( ( '<' | '>' | LE_OP2 | GE_OP2 ) shift_expr )*
shift_expr
::= additive_expr ( ( SHRIGHT | SHLEFT ) additive_expr )*
additive_expr
::= multiplicative_expr ( ( '+' | '-' ) multiplicative_expr )*
multiplicative_expr
::= primary_expr ( ( '*' | '/' | '%' ) primary_expr )*
primary_expr
::= ICONSTANT
| ID_EXPRESSION
| '(' expression ')'
unary_expr
::= ( PLUSPLUS | MINUSMINUS )* postfix_expr
postfix_expr
::= primary_expr ( '[' expression ( ':' expression )? ']' | PLUSPLUS | MINUSMINUS )*
variable_list
::= ID_EXPRESSION ( ',' ID_EXPRESSION )*
id_expression_opt_dimension
::= ID_EXPRESSION dimension_field_optseq
dimension_field_optseq
::= dimension_field*
dimension_field
::= '[' expression ':' expression ']'
//
// Tokens
//
//\(\S+\)\s+{\s*return.*?(\s*\(\S+\)\s*);\s*} -> \2 ::= "\1"
OMP ::= "omp"
PARALLEL ::= "parallel"
TASK ::= "task"
TASKWAIT ::= "taskwait"
UNTIED ::= "untied"
MERGEABLE ::= "mergeable"
IF ::= "if" /*if is a keyword in C/C++, no change to be a variable*/
NUM_THREADS ::= "num_threads"
ORDERED ::= "ordered"
SCHEDULE ::= "schedule"
STATIC ::= "static" /*keyword in C/C++ */
DYNAMIC ::= "dynamic"
GUIDED ::= "guided"
RUNTIME ::= "runtime"
AUTO ::= "auto" /*keyword in C/C++ ?*/
SECTIONS ::= "sections"
SECTION ::= "section"
SINGLE ::= "single"
NOWAIT ::= "nowait"
FOR ::= "for" /*keyword in C/C++ */
COLLAPSE ::= "collapse"
MASTER ::= "master"
CRITICAL ::= "critical"
BARRIER ::= "barrier"
ATOMIC ::= "atomic"
FLUSH ::= "flush"
THREADPRIVATE ::= "threadprivate"
PRIVATE ::= "private"
COPYPRIVATE ::= "copyprivate"
FIRSTPRIVATE ::= "firstprivate"
LASTPRIVATE ::= "lastprivate"
DEFAULT ::= "default"
SHARED ::= "shared"
NONE ::= "none"
REDUCTION ::= "reduction"
MIN ::= "min"
MAX ::= "max"
COPYIN ::= "copyin"
INBRANCH ::= "inbranch"
NOTINBRANCH ::= "notinbranch"
PROC_BIND ::= "proc_bind"
CLOSE ::= "close"
SPREAD ::= "spread" /* master should already be recognized */
DEPEND ::= "depend"
IN ::= "in"
OUT ::= "out"
INOUT ::= "inout"
READ ::= "read"
WRITE ::= "write"
CAPTURE ::= "capture"
TARGET ::= "target"
MPI ::= "mpi" /*Experimental keywords to support scaling up to MPI processes */
MPI_ALL ::= "mpi:all"
MPI_MASTER ::= "mpi:master"
TARGET_BEGIN ::= "begin"
TARGET_END ::= "end"
DECLARE ::= "declare"
DATA ::= "data"
UPDATE ::= "update"
MAP ::= "map"
DEVICE ::= "device"
ALLOC ::= "alloc"
TO ::= "to" //{return cond_return ( TO ); /* change the user level keyword to conform to OpenMP 4.0 */}
FROM ::= "from"
TOFROM ::= "tofrom"
SIMD ::= "simd"
SAFELEN ::= "safelen"
SIMDLEN ::= "simdlen"
ALIGNED ::= "aligned"
LINEAR ::= "linear"
UNIFORM ::= "uniform"
FINAL ::= "final"
PRIORITY ::= "priority"
DIST_DATA ::= "dist_data" /*Extensions for data distribution clause
It is tricky to support mixed variable vs. keyword parsing for dist_data() since it is part of variable list parsing
We enforce that users won't use variable names colliding with the keywords (no cond_return() is used)
TODO: later we can relax this restriction. Fine-grain control of cond_return with new flags.
*/
BLOCK ::= "block"
DUPLICATE ::= "duplicate"
CYCLIC ::= "cyclic"
BLOCK ::= "BLOCK"
DUPLICATE ::= "DUPLICATE"
CYCLIC ::= "CYCLIC"
LOGAND ::= "&&"
LOGOR ::= "||"
SHLEFT ::= "<<"
SHRIGHT ::= ">>"
PLUSPLUS ::= "++"
MINUSMINUS ::= "--"
RIGHT_ASSIGN2 ::= ">>="
LEFT_ASSIGN2 ::= "<<="
ADD_ASSIGN2 ::= "+="
SUB_ASSIGN2 ::= "-="
MUL_ASSIGN2 ::= "*="
DIV_ASSIGN2 ::= "/="
MOD_ASSIGN2 ::= "%="
AND_ASSIGN2 ::= "&="
XOR_ASSIGN2 ::= "^="
OR_ASSIGN2 ::= "|="
LE_OP2 ::= "<="
GE_OP2 ::= ">="
EQ_OP2 ::= "=="
NE_OP2 ::= "!="
//"\\" { /*printf("found a backslash\n"); This does not work properly but can be ignored*/}
PTR_TO ::= "->"
And here is the EBNF
for https://github.com/rose-compiler/rose/blob/weekly/src/midend/programAnalysis/annotationLanguageParser/language.y
/* converted on Mon Nov 14, 2022, 15:43 (UTC+01) by bison-to-w3c v0.62 which is Copyright (c) 2011-2022 by Gunther Rademacher <grd@gmx.net> */
annotation_file
::= annotation+
annotation
::= global
| property
| ( tokENABLE | tokDISABLE ) tokID
| procedure
| pattern
| analyze_annotation
global ::= tokGLOBAL ( '{' structures '}' | structure )
property ::= tokMAYPROPERTY tokID ':' ( optional_direction user_defined_class optional_diagnostic optional_default | tokUNION_SET | tokUNION_EQUIV )
| tokMUSTPROPERTY tokID ':' ( optional_direction user_defined_class optional_diagnostic optional_default | tokINTERSECT_SET | tokINTERSECT_EQUIV )
optional_direction
::= ( tokFORWARD | tokBACKWARD )?
optional_default
::= ( tokINITIALLY tokID )?
optional_diagnostic
::= ( tokDIAGNOSTIC '{' identifier_list '}' )?
user_defined_class
::= '{' member ( ',' member )* '}'
member ::= tokID user_defined_class?
procedure
::= procedure_declaration '{' procedure_annotation* '}'
procedure_declaration
::= tokPROCEDURE tokID '(' identifier_list? ')'
procedure_annotation
::= structure_annotation
| behavior_annotation
| analyze_annotation
| report_annotation
structure_annotation
::= ( tokON_ENTRY '{' structures? | tokON_EXIT '{' ( structures | pointer_rule* ) ) '}'
pointer_rule
::= ( tokIF '(' condition ')' | tokDEFAULT ) ( '{' structures '}' | structure )
structures
::= ( structure | tokDELETE qualified_identifier ) ( ','? ( structure | tokDELETE qualified_identifier ) )*
structure
::= ( tokID tokARROW tokNEW? )* ( qualified_identifier | tokID '{' structures '}' )
behavior_annotation
::= ( tokACCESS | tokMODIFY ) ( '{' identifier_list '}' | tokID )
analyze_annotation
::= tokANALYZE tokID '{' ( rule+ | effects ) '}'
rule ::= ( tokIF '(' condition ')' | tokDEFAULT ) ( '{' effects '}' | effect )
condition
::= test
| ( condition ( tokOROR | tokANDAND ) | '!' ) condition
| '(' condition ')'
test ::= tokID ( ( ':' tokID )? property_sensitivity ( tokIS_BOTTOM | binary_property_operator tokID ) | ( tokID | tokIS_ELEMENT_OF | tokIS_ALIASOF | tokIS_SAMEAS ) tokID | tokIS_EMPTYSET | tokIS_CONSTANT | tokIS_EMPTY )
effects ::= effect+
effect ::= ( tokID ( tokASSIGN | tokWEAKASSIGN | tokID ) | tokADD ) tokID
binary_property_operator
::= tokIS_EXACTLY
| tokIS_ATLEAST
| tokCOULD_BE
| tokIS_ATMOST
property_sensitivity
::= ( tokBEFORE | tokAFTER | tokALWAYS | tokEVER | tokTRACE | tokCONFIDENCE )?
report_annotation
::= ( tokREPORT | tokERROR ) ( tokIF '(' condition ')' )? report_element_list ';'
report_element_list
::= report_element ( tokAPPEND report_element )*
report_element
::= tokSTRING
| tokID ':' tokID property_sensitivity
| '@' tokID
| '[' tokID ']'
| '|' tokID '|'
pattern ::= tokPATTERN
identifier_list
::= qualified_identifier ( ',' qualified_identifier )*
qualified_identifier
::= tokIO? tokID
//
// Tokens
//
tokMAYPROPERTY ::= "property"
tokMAYPROPERTY ::= "may-property"
tokMUSTPROPERTY ::= "must-property"
tokINITIALLY ::= "initially"
tokDIAGNOSTIC ::= "diagnostic"
tokGLOBAL ::= "global"
tokPROCEDURE ::= "procedure"
tokENABLE ::= "enable"
tokDISABLE ::= "disable"
tokACCESS ::= "access"
tokMODIFY ::= "modify"
tokANALYZE ::= "analyze"
tokDEFAULT ::= "default"
tokIF ::= "if"
tokIS_EXACTLY ::= "is-exactly"
tokCOULD_BE ::= "could-be"
tokIS_ATLEAST ::= "is-atleast"
tokIS_ATMOST ::= "is-atmost"
tokIS_BOTTOM ::= "is-??"
tokBEFORE ::= "@before"
tokAFTER ::= "@after"
tokALWAYS ::= "@always"
tokEVER ::= "@ever"
tokTRACE ::= "@trace"
tokCONFIDENCE ::= "@confidence"
tokFORWARD ::= "@forward"
tokBACKWARD ::= "@backward"
tokIS_ALIASOF ::= "is-aliasof"
tokIS_SAMEAS ::= "is-sameas"
tokIS_EMPTY ::= "is-empty"
tokON_ENTRY ::= "on_entry"
tokON_EXIT ::= "on_exit"
tokNEW ::= "new"
tokARROW ::= "-->"
tokDELETE ::= "delete"
tokPATTERN ::= "pattern"
tokANDAND ::= "&&"
tokOROR ::= "||"
tokNOT_EQUALS ::= "!="
tokEQUALS_EQUALS ::= "=="
tokLESS_EQUALS ::= "<="
tokGREATER_EQUALS ::= ">="
tokIS_CONSTANT ::= "is-#"
tokEQUALS ::= "="
tokASSIGN ::= "<-"
tokWEAKASSIGN ::= "<-+"
tokREPORT ::= "report"
tokERROR ::= "error"
tokAPPEND ::= "++"
tokWHEN ::= "when"
tokREPLACE ::= "replace-with"
tokINLINE ::= "inline"
tokUNION_SET ::= "{union-set}"
tokINTERSECT_SET ::= "{intersect-set}"
tokUNION_EQUIV ::= "{union-equivalence}"
tokINTERSECT_EQUIV ::= "{intersect-equivalence}"
tokIS_ELEMENT_OF ::= "is-element-of"
tokIS_EMPTYSET ::= "is-{}"
tokADD ::= "set-add"
tokIO ::= "I/O"
/* -- Embedded meta-tokens ------------------------------------------------------------ */
metatokEXPR ::= "expr"
metatokSTMT ::= "stmt"
metatokTYPE ::= "type"
We no specific action required, we will archive this information.
Looking through this project I found this
C++11
grammar https://github.com/rose-compiler/rose/blob/weekly/src/3rdPartyLibraries/experimental-cplusplus-parser/Main.sdf and with a bit ofLua
like string patterns substitutions I managed to convert it to anEBNF
understood by https://www.bottlecaps.de/rr/ui .Copy and paste the
EBNF
shown bellow at https://www.bottlecaps.de/rr/ui on the tabEdit Grammar
then click on the tabView Diagram
to get a navigable railroad diagram.