/** * This is an experimental COBOL-85 grammar for JavaCC. *

References used for this grammar :

    *
  1. Ralf Lämmel & Chris Verhoef : VS COBOL II grammar Version 1.0.3 *
  2. Fujitsu Cobol compiler reference *
  3. Compaq-HP Non-stop Cobol reference * *

    This grammar is released under the GNU Library Public License (LGPL). *

    Bernard Pinon, august 2002
    * @see http://www.gnu.org/licenses/lgpl.html * @see http://www.cwi.nl/ * @see http://www.wins.uva.nl/ * @author Bernard Pinon (bpinon at benjamin dash media dot com) * *

    History:

    */ /** * Cobol is not case sensitive. It is not LL(1) neither... */ options { IGNORE_CASE = true; //FORCE_LA_CHECK = true; LOOKAHEAD = 4; //DEBUG_PARSER = true; //DEBUG_LOOKAHEAD = true; } /** * The parser class. */ PARSER_BEGIN(CobolParser) package testparser; public class CobolParser { } PARSER_END(CobolParser) //////////////////////////////////////////////////////////////////////////////// // Lexical structure //////////////////////////////////////////////////////////////////////////////// SPECIAL_TOKEN : { | } SPECIAL_TOKEN : { " (~["\n","\r"])* > | < SPACE_SEPARATOR : ( | )+ > | < COMMA_SEPARATOR : "," > } TOKEN : { > } //////////////////////////////////////////////////////////////////////////////// // RESERVED WORDS. Looks like an excerpt of the dictionary of data processing. // It is very hard to find significative identifiers in COBOL that are not // reserved... //////////////////////////////////////////////////////////////////////////////// TOKEN : { /* A */ < ACCEPT: "accept" > | < ACCESS: "access" > | < ADD: "add" > | < ADDRESS: "address" > // extension to support pointers | < ADVANCING: "advancing" > | < AFTER: "after" > | < ALL: "all" > | < ALPHABET: "alphabet" > | < ALPHABETIC: "alphabetic" > | < ALPHABETIC_LOWER: "alphabetic-lower" > | < ALPHABETIC_UPPER: "alphabetic-upper" > | < ALPHANUMERIC: "alphanumeric" > | < ALPHANUMERIC_EDITED: "alphanumeric-edited" > | < ALSO: "also" > | < ALTER: "alter" > | < ALTERNATE: "alternate" > | < AND: "and" > | < ANY: "any" > | < APPROXIMATE: "approximate" > // tandem extension | < ARE: "are" > | < AREA: "area" > | < AREAS: "areas" > | < ASCENDING: "ascending" > | < ASSIGN: "assign" > | < AT: "at" > | < AUTHOR: "author" > /* B */ | < BEFORE: "before" > | < BEGINNING: "beginning" > // extension | < BINARY: "binary" > | < BLANK: "blank" > | < BLOCK: "block" > | < BOTTOM: "bottom" > | < BY: "by" > /* C */ | < CALL: "call" > | < CANCEL: "cancel" > | < CD: "cd" > | < CF: "cf" > | < CH: "ch" > | < CHARACTER: "character"> | < CHARACTERS: "characters"> | < CLASS: "class" > | < CLOCK_UNITS: "clock-units" > | < CLOSE: "close" > | < COBOL: "cobol" > | < CODE: "code" > | < CODE_SET: "code-set" > | < COLLATING: "collating" > | < COLUMN: "column" > | < COMMA: "comma" > | < COMMON: "common" > | < COMMUNICATION: "communication" > | < COMP: "comp" > | < COMP_1: "comp-1" > // extension in many dialects | < COMP_2: "comp-2" > // extension in many dialects | < COMP_3: "comp-3" > // extension in many dialects | < COMP_4: "comp-4" > // extension in many dialects | < COMPUTATIONAL: "computational" > | < COMPUTATIONAL_1: "computational-1" > // extension | < COMPUTATIONAL_2: "computational-2" > // extension | < COMPUTATIONAL_3: "computational-3" > // extension | < COMPUTATIONAL_4: "computational-4" > // extension | < COMPUTE: "compute" > | < CONFIGURATION: "configuration" > | < CONTAINS: "contains" > | < CONTENT: "content" > | < CONTINUE: "continue" > | < CONTROL: "control" > | < CONTROLS: "controls" > | < CONVERTING: "converting" > | < COPY: "copy" > | < CORR: "corr" > | < CORRESPONDING: "corresponding" > | < COUNT: "count" > | < CURRENCY: "currency" > /* D */ | < DATA: "data" > | < DATE: "date" > | < DATE_COMPILED: "date-compiled" > | < DATE_WRITTEN: "date-written" > | < DAY: "day" > | < DAY_OF_WEEK: "day-of-week" > | < DBCS: "dbcs" > // extension to support double bytes characters | < DE: "de" > | < DEBUG_CONTENTS: "debug-contents" > | < DEBUG_ITEM: "debug-item" > | < DEBUG_LINE: "debug-line" > | < DEBUG_NAME: "debug-name" > | < DEBUG_SUB_1: "debug-sub-1" > | < DEBUG_SUB_2: "debug-sub-2" > | < DEBUG_SUB_3: "debug-sub-3" > | < DEBUGGING: "debugging" > | < DECIMAL_POINT: "decimal-point" > | < DECLARATIVES: "declaratives" > | < DELETE: "delete" > | < DELIMITED: "delimited" > | < DELIMITER: "delimiter" > | < DEPENDING: "depending" > | < DESCENDING: "descending" > | < DESTINATION: "destination" > | < DETAIL: "detail" > | < DISABLE: "disable" > | < DISPLAY: "display" > | < DISPLAY_1: "display-1" > // extension | < DIVIDE: "divide" > | < DIVISION: "division" > | < DOWN: "down" > | < DUPLICATES: "duplicates" > | < DYNAMIC: "dynamic" > /* E */ | < EGCS: "egcs" > // extension | < EGI: "egi" > | < ELSE: "else" > | < EMI: "emi" > | < ENABLE: "enable" > | < END: "end" > | < END_ADD: "end-add" > | < END_CALL: "end-call" > | < END_COMPUTE: "end-compute" > | < END_DELETE: "end-delete" > | < END_DIVIDE: "end-divide" > | < END_EVALUATE: "end-evaluate" > | < END_IF: "end-if" > | < END_MULTIPLY: "end-multiply" > | < END_OF_PAGE: "end-of-page" > | < END_PERFORM: "end-perform" > | < END_READ: "end-read" > | < END_RECEIVE: "end-receive" > | < END_RETURN: "end-return" > | < END_REWRITE: "end-rewrite" > | < END_SEARCH: "end-search" > | < END_START: "end-start" > | < END_STRING: "end-string" > | < END_SUBTRACT: "end-subtract" > | < END_UNSTRING: "end-unstring" > | < END_WRITE: "end-write" > | < ENDING: "endinf" > | < ENTER: "enter" > // not present in all COBOLs, use CALL instead | < ENTRY: "entry" > | < ENVIRONMENT: "environment" > | < EOP: "eop" > | < EQUAL: "equal" > | < ERROR: "error" > | < ESI: "esi" > | < EVALUATE: "evaluate" > | < EVERY: "every" > | < EXCEPTION: "exception" > /* | < EXCLUSIVE: "exclusive" > tandem extension */ | < EXIT: "exit" > | < EXTEND: "extend" > | < EXTERNAL: "external" > /* F */ | < FALSE: "false" > | < FD: "fd" > | < FILE: "file" > | < FILE_CONTROL: "file-control" > | < FILLER: "filler" > | < FINAL: "final" > | < FIRST: "first" > | < FOOTING: "footing" > | < FOR: "for" > | < FROM: "from" > | < FUNCTION: "function" > /* G */ | < GENERATE: "generate" > | < GOBACK: "goback" > // extension | < GENERIC: "generic" > // tandem extension | < GIVING: "giving" > | < GLOBAL: "global" > | < GO: "go" > | < GREATER: "greater" > | < GROUP: "group" > /* H */ | < HEADING: "heading" > | < HIGH_VALUE: "high-value" > | < HIGH_VALUES: "high-values" > /* I */ | < I_O: "i-o" > | < I_O_CONTROL: "i-o-control" > | < ID: "id" > // extension, synonym for IDENTIFICATION | < IDENTIFICATION: "identification" > | < IF: "if" > | < IMPLICIT: "implicit" > | < IN: "in" > | < INDEX: "index" > | < INDEXED: "indexed" > | < INDICATE: "indicate" > | < INITIAL: "initial" > | < INITIALIZE: "initialize" > | < INITIATE: "initiate" > | < INPUT: "input" > | < INPUT_OUTPUT: "input-output" > | < INSPECT: "inspect" > | < INSTALLATION: "installation" > | < INTO: "into" > | < INVALID: "invalid" > | < IS: "is" > /* J */ | < JUST: "just" > | < JUSTIFIED: "justified" > | < JUSTIFY: "justify" > /* K */ | < KANJI: "kanji" > // extension to support Kanji characters (japanese) | < KEY: "key" > /* L */ | < LABEL: "label" > | < LAST: "last" > | < LEADING: "leading" > | < LEFT: "left" > | < LENGTH: "length" > | < LESS: "less" > | < LIMIT: "limit" > | < LIMITS: "limits" > | < LINAGE: "linage" > | < LINAGE_COUNTER: "linage_counter" > | < LINE: "line" > | < LINES: "lines" > | < LINE_COUNTER: "line-counter" > | < LINKAGE: "linkage" > | < LOCK: "lock" > | < LOCKFILE: "lockfile" > // tandem extension | < LOW_VALUE: "low-value" > | < LOW_VALUES: "low-values" > /* M */ | < MEMORY: "memory" > | < MERGE: "merge" > | < MESSAGE: "message" > | < MODE: "mode" > | < MODULES: "modules" > | < MORE_LABELS: "more-labels" > // IBM extension | < MOVE: "move" > | < MULTIPLE: "multiple" > | < MULTIPLY: "multiply" > /* N */ | < NATIVE: "native" > | < NEGATIVE: "negative" > | < NEXT: "next" > | < NO: "no" > | < NOT: "not" > | < NULL: "null" > // tandem & IBM extension | < NULLS: "nulls" > // tandem & IBM extension | < NUMBER: "number" > | < NUMERIC: "numeric" > | < NUMERIC_EDITED: "numeric-edited" > /* O */ | < OBJECT_COMPUTER: "object-computer" > | < OCCURS: "occurs" > | < OF: "of" > | < OFF: "off" > | < OMITTED: "omitted" > | < ON: "on" > | < OPEN: "open" > | < OPTIONAL: "optional" > | < OR: "or" > | < ORDER: "order" > | < ORGANIZATION: "organization" > | < OTHER: "other" > | < OUTPUT: "output" > | < OVERFLOW: "overflow" > /* P */ | < PACKED_DECIMAL: "packed-decimal" > | < PADDING: "padding" > | < PAGE: "page" > | < PAGE_COUNTER: "page-counter" > | < PASSWORD: "password" > | < PERFORM: "perform" > | < PF: "pf" > | < PH: "ph" > | < PIC: "pic" > | < PICTURE: "picture" > | < PLUS: "plus" > | < POINTER: "pointer" > | < POSITION: "position" > | < POSITIVE: "positive" > | < PRINTING: "printing" > | < PROCEDURE: "procedure" > | < PROCEDURES: "procedures" > | < PROCEED: "proceed" > | < PROGRAM: "program" > | < PROGRAM_ID: "program-id" > | < PROGRAM_STATUS: "program-status" > // tandem extension | < PROMPT: "prompt" > // tandem extension | < PROTECTED: "protected" > // tandem extension | < PURGE: "purge" > /* Q */ | < QUEUE: "queue" > | < QUOTE: "quote" > | < QUOTES: "quotes" > /* R */ | < RANDOM: "random" > | < RD: "rd" > | < READ: "read" > | < RECEIVE: "receive" > | < RECEIVE_CONTROL: "receive-control" > // tandem extension | < RECORD: "record" > | < RECORDING: "recording" > // probably IBM extension | < RECORDS: "records" > | < REDEFINES: "redefines" > | < REEL: "reel" > | < REFERENCE: "reference" > | < REFERENCES: "references" > | < RELATIVE: "relative" > | < RELEASE: "release" > | < REMAINDER: "remainder" > | < REMOVAL: "removal" > | < RENAMES: "renames" > | < REPLACE: "replace" > | < REPLACING: "replacing" > | < REPLY: "reply" > // tandem extension | < REPORT: "report" > | < REPORTING: "reporting" > | < REPORTS: "reports" > | < RERUN: "rerun" > | < RESERVE: "reserve" > | < RESET: "reset" > | < RETURN: "return" > // IBM extension - does not do what expected ;-) | < RETURN_CODE: "return-code" > // special register IBM | < RETURNED: "returned" > | < REVERSED: "reversed" > | < REWIND: "rewind" > | < REWRITE: "rewrite" > | < RF: "rf" > | < RH: "rh" > | < RIGHT: "right" > | < ROUNDED: "rounded" > | < RUN: "run" > /* S */ | < SAME: "same" > | < SD: "sd" > | < SEARCH: "search" > | < SECTION: "section" > | < SECURITY: "security" > | < SEGMENT: "segment" > | < SEGMENT_LIMIT: "segment-limit" > | < SELECT: "select" > | < SEND: "send" > | < SENTENCE: "sentence" > | < SEPARATE: "separate" > | < SEQUENCE: "sequence" > | < SEQUENTIAL: "sequential" > | < SET: "set" > | < SHARED: "shared" > // tandem extension, should be in C2000 | < SHIFT_IN: "shift-in" > // IBM special register | < SHIFT_OUT: "shift-out" > // IBM special register | < SIGN: "sign" > | < SIZE: "size" > | < SORT: "sort" > | < SORT_CONTROL: "sort-control" > // IBM special register | < SORT_CORE_SIZE: "sort-core-size" > // IBM special register | < SORT_FILE_SIZE: "sort-file-size" > // IBM special register | < SORT_MERGE: "sort-merge" > | < SORT_MESSAGE: "sort-message" > // IBM special register | < SORT_MODE_SIZE: "sort-mode-size" > // IBM special register | < SORT_RETURN: "sort-return" > // IBM special register | < SOURCE: "source" > | < SOURCE_COMPUTER: "source-computer" > | < SPACE: "space" > | < SPACES: "spaces" > | < SPECIAL_NAMES: "special-names" > | < STANDARD: "standard" > | < STANDARD_1: "standard-1" > | < STANDARD_2: "standard-2" > | < START: "start" > | < STATUS: "status" > | < STOP: "stop" > | < STRING: "string" > | < SUB_QUEUE_1: "sub-queue-1" > | < SUB_QUEUE_2: "sub-queue-2" > | < SUB_QUEUE_3: "sub-queue-3" > | < SUBTRACT: "subtract" > | < SUM: "sum" > | < SUPPRESS: "suppress" > | < SYMBOLIC: "symbolic" > | < SYNC: "sync" > | < SYNCHRONIZED: "synchronized" > /* T */ | < TABLE: "table" > | < TALLY: "tally" > // IBM special register | < TALLYING: "tallying" > | < TAPE: "tape" > | < TERMINAL: "terminal" > | < TERMINATE: "terminate" > | < TEST: "test" > | < TEXT: "text" > | < THAN: "than" > | < THEN: "then" > | < THROUGH: "through" > | < THRU: "thru" > | < TIME: "time" > | < TIMES: "times" > | < TO: "to" > | < TOP: "top" > | < TRAILING: "trailing" > | < TRUE: "true" > | < TYPE: "type" > /* U */ | < UNIT: "unit" > | < UNLOCK: "unlock" > // tandem extension | < UNLOCKFILE: "unlockfile" > // tandem again | < UNLOCKRECORD: "unlockrecord" > // guess what | < UNSTRING: "unstring" > | < UNTIL: "until" > | < UP: "up" > | < UPON: "upon" > | < USAGE: "usage" > | < USE: "use" > | < USING: "using" > /* V */ | < VALUE: "value" > | < VALUES: "values" > | < VARYING: "varying" > /* W */ | < WHEN: "when" > | < WHEN_COMPILED: "when-compiled" > // IBM special register | < WITH: "with" > | < WORDS: "words" > | < WORKING_STORAGE: "working-storage" > | < WRITE: "write" > /* Z */ | < ZERO: "zero" > | < ZEROS: "zeros" > | < ZEROES: "zeroes" > } TOKEN : { < HEXNUMBER: ( "X\"" ( ["0"-"9","a"-"f"] )+ "\"" | "X'" ( ["0"-"9","a"-"f"] )+ "'" ) > | < LEVEL_66: "66" > | < LEVEL_77: "77" > | < LEVEL_88: "88" > | < LEVEL_NUMBER: ( ("0" ["1"-"9"]) | (["1"-"4"]["0"-"9"]) )> | < INTEGER: (["0"-"9"])+ > | < MINUSCHAR: "-" > // a.k.a. dash | < LPARENCHAR: "(" > | < RPARENCHAR: ")" > | < COLONCHAR: ":" > | < DOTCHAR: "." > | < COMMACHAR: "," > | < DOUBLEDQUOTECHAR: "\"\"" > | < QUOTECHAR: "\"" > | < DOUBLEDAPOSTROPHE: "''" > | < APOSTROPHE: "'" > | < PLUSCHAR: "+" > | < ASTERISKCHAR: "*" > | < SLASHCHAR: "/" > | < DOLLARCHAR: "$" > | < LESSTHANOREQUAL: "<=" > | < LESSTHANCHAR: "<" > | < MORETHANOREQUAL: ">=" > | < MORETHANCHAR: ">" > | < EQUALCHAR: "=" > | < QUOTEDSTRING: ( (~["\""] | )* | (~["'"] | )* ) > | )*)* (["0"-"9"])* ["a"-"z"] ( ["a"-"z","0"-"9"] )* ( ()+ (["a"-"z","0"-"9"])+)* > } void CobolWord () : // contains at least one alphabetic, max. 30 char {} { } void IntegerConstant() : {} { | | | | } void NumericConstant() : {} { (|)? IntegerConstant() [ IntegerConstant() ] } void LevelNumber() : {} { } void FigurativeConstant() : {} { | | | | | | | | | | | | } void NonNumericConstant() : {} { ( ( )+ | ) } void Literal() : {} { [ ] ( NonNumericConstant() | NumericConstant() /* | */ | FigurativeConstant() ) } //////////////////////////////////////////////////////////////////////////////// // LOGICAL EXPRESSIONS (e.g. in IF statements) // one of the nice feature of COBOL is to allow for abbeviated conditions // such as : if X less than 100 and more than 10 then ... //////////////////////////////////////////////////////////////////////////////// void Condition() : {} { CombinableCondition() ( ( | ) ( CombinableCondition() | AbbreviationRest() ) )* } void CombinableCondition() : {} { [] SimpleCondition() } void SimpleCondition() : {} { ( Condition() | RelationCondition() | ClassCondition() | ConditionNameCondition() ) } void ClassCondition() : {} { Identifier() [ ] [ ] ( | | | | ClassName() | | ) } void ConditionNameCondition() : {} { ConditionNameReference() } void RelationCondition() : {} { ArithmeticExpression() ( RelationalOperator() ArithmeticExpression() | SignCondition() ) } void SignCondition() : {} { [ ] [ ] ( | | ) } void RelationalOperator() : {} { [ ] ( [ ] ( [ ] | | [ ] | | [ ] | ) | [ ] [ ] | | [ ] [ ] | ) } void AbbreviationRest() : {} { ( [ ] [ RelationalOperator() ] AbbreviationLeaf() )+ } void AbbreviationLeaf() : {} { ( ArithmeticExpression() | ArithmeticExpression() AbbreviationRest() ) } //////////////////////////////////////////////////////////////////////////////// // VARIOUS TYPES OF IDENTIFIERS //////////////////////////////////////////////////////////////////////////////// void ProcedureName() : {} { ( ParagraphName() [ ( | ) SectionName() ] | SectionName() ) } void Identifier() : {} { ( QualifiedDataName() ( Subscript() )* [ LeftmostCharacterPosition() [ Length() ] ] | [ ( | ) FileName() ] ) } void QualifiedDataName() : {} { ( DataName() ( ( | ) DataName() )* [ ( | ) FileName() ] | SpecialRegister() ) } void Length() : {} { ArithmeticExpression() } void LeftmostCharacterPosition() : {} { ArithmeticExpression() } void ConditionNameReference() : {} { ConditionName() ( ( ( | ) DataName() )* [ ( | ) FileName() ] ( Subscript() )* | ( ( | ) MnemonicName() )* ) } void Subscript() : {} { ( IntegerConstant() | QualifiedDataName() [ ( | ) IntegerConstant() ] | IndexName() [ ( | ) IntegerConstant() ] )+ } void Mode() : {} { CobolWord() } void AlphabetName() : {} { CobolWord() } void ClassName() : {} { CobolWord() } void ConditionName() : {} { CobolWord() } void DataName() : {} { CobolWord() } void FileName() : {} { CobolWord() } void IndexName() : {} { CobolWord() } void MnemonicName() : {} { CobolWord() } void RecordName() : {} { QualifiedDataName() } void RoutineName() : {} { CobolWord() } void SymbolicCharacter() : {} { CobolWord() } void LibraryName() : {} { CobolWord() } void ProgramName() : {} { CobolWord() } void SectionName() : {} { CobolWord() } void ParagraphName() : {} { CobolWord() } void SystemName() : {} { CobolWord() } void ComputerName() : {} { SystemName() } void LanguageName() : {} { SystemName() } void EnvironmentName() : {} { SystemName() } void AssignmentName() : {} { SystemName() } void BasisName() : {} { ProgramName() } void SpecialRegister() : {} { (
    DataName() | | Identifier() | | | | | | | | | | | ) } //////////////////////////////////////////////////////////////////////////////// // ARITHMETIC //////////////////////////////////////////////////////////////////////////////// void ArithmeticExpression() : {} { TimesDiv() ( ( | ) TimesDiv() )* } void TimesDiv() : {} { Power() ( ( | ) Power() )* } void Power() : {} { [ ( | ) ] Basis() ( "**" Basis() )* } void Basis() : {} { ( Identifier() | Literal() | ArithmeticExpression() ) } void CommentLine() : {} { ( ( ( )+ | ) )+ } //////////////////////////////////////////////////////////////////////////////// // COMPILATION UNIT. //////////////////////////////////////////////////////////////////////////////// void CompilationUnit() : {} { ProgramUnit() ( NestedProgramUnit() EndProgramStatement() )* [ EndProgramStatement() ( CompilationUnit() )* ] } void ProgramUnit() : {} { IdentificationDivision() [ EnvironmentDivision() ] [ DataDivision() ] [ ProcedureDivision() ] } void NestedProgramUnit() : {} { NestedIdentificationDivision() [ EnvironmentDivision() ] [ DataDivision() ] [ ProcedureDivision() ] } void EndProgramStatement() : {} { ProgramName() } //////////////////////////////////////////////////////////////////////////////// // IDENTIFICATION DIVISION. //////////////////////////////////////////////////////////////////////////////// void IdentificationDivision() : {} { ProgramIdParagraph() ( IdentificationDivisionParagraph() )* } void NestedIdentificationDivision() : {} { ( | ) NestedProgramIdParagraph() ( IdentificationDivisionParagraph() )* } void IdentificationDivisionParagraph() : {} { AuthorParagraph() | InstallationParagraph() | DateWrittenParagraph() | DateCompiledParagraph() | SecurityParagraph() } void ProgramIdParagraph() : {} { ProgramName() [ [ ] [ ] ] } void NestedProgramIdParagraph() : {} { ProgramName() [ [ ] InitialOrCommon() [ ] ] } void InitialOrCommon() : {} { ( [ ] | [ ] ) } void AuthorParagraph() : { //System.out.println("Deprecated keyword : author - use a comment"); } { [ CommentLine() ] } void InstallationParagraph() : { //System.out.println("Deprecated keyword : installation - use a comment"); } { [ CommentLine() ] } void DateWrittenParagraph() : { //System.out.println("Deprecated keyword : date-written - use a comment"); } { [ CommentLine() ] } void DateCompiledParagraph() : { //System.out.println("Deprecated keyword : date-compiled - use a comment"); } { [ CommentLine() ] } void SecurityParagraph() : { //System.out.println("Deprecated keyword : security - use a comment"); } { [ CommentLine() ] } //////////////////////////////////////////////////////////////////////////////// // ENVIRONMENT DIVISION. //////////////////////////////////////////////////////////////////////////////// void EnvironmentDivision() : {} { ( EnvironmentSection() )* } void EnvironmentSection() : {} { ConfigurationSection() | InputOutputSection() } //------------------------------------------------------------------------------ // CONFIGURATION SECTION //------------------------------------------------------------------------------ void ConfigurationSection() : {} {
    ( ConfigurationSectionParagraph() )* } void ConfigurationSectionParagraph() : {} { SourceComputerParagraph() | ObjectComputerParagraph() | SpecialNamesParagraph() } void SourceComputerParagraph() : {} { ComputerName() [ [ ] ] } void ObjectComputerParagraph() : {} { ComputerName() ( ObjectComputerClause() )* } void ObjectComputerClause() : {} { MemorySizeClause() | CollatingSequenceClause() | SegmentLimitClause() | CharacterSetClause() } void MemorySizeClause() : { //System.out.println("Deprecated keyword : memory - use a comment"); } { [ ] IntegerConstant() [ | | ] } void CollatingSequenceClause() : { //System.out.println("Deprecated keyword : collating sequence - use a comment"); } { [ ] [ ] [ ] AlphabetName() } void SegmentLimitClause() : { //System.out.println("Deprecated keyword : segment unit - use a comment"); } { [ ] IntegerConstant() } void CharacterSetClause() : {} { // Tandem ??? [ CommentLine() ] } void SpecialNamesParagraph() : {} { [ SpecialNameClause() ( SpecialNameClause() )* ] } void SpecialNameClause() : {} { AlphabetClause() | ClassClause() | CurrencySignClause() | DecimalPointClause() | SymbolicCharactersClause() | EnvironmentNameIsMnemonicNameClause() } void AlphabetClause() : {} { AlphabetName() [ ] ( | | | CobolWord() | ( Literal() [ ( ( | ) Literal() | ( Literal() )+ ) ] )+ ) } void ClassClause() : {} { ClassName() [ ] ( Literal() [ ( | ) Literal() ] )+ } void CurrencySignClause() : {} { [ ] [ ] Literal() } void DecimalPointClause() : {} { [ ] } void SymbolicCharactersClause() : {} { [ ] ( ( SymbolicCharacter() )+ [ ( | ) ] ( IntegerConstant() )+ )+ [ AlphabetName() ] } void EnvironmentNameIsMnemonicNameClause() : {} { ( EnvironmentName() [ ] MnemonicName() [ SpecialNamesParagraphStatusPhrase() ] | SpecialNamesParagraphStatusPhrase() ) } void SpecialNamesParagraphStatusPhrase() : {} { ( [ ] [ ] Condition() [ [ ] [ ] Condition() ] | [ ] [ ] Condition() [ [ ] [ ] Condition() ] ) } //------------------------------------------------------------------------------ // INPUT-OUTPUT SECTION //------------------------------------------------------------------------------ void InputOutputSection() : {} {
    ( InputOutputSectionParagraph() )* } void InputOutputSectionParagraph() : {} { FileControlParagraph() | IOControlParagraph() } void FileControlParagraph() : {} { ( [ ] FileControlEntry() )+ } void FileControlEntry() : {} { SelectClause() AssignClause() ( FileControlClause() )* } void FileControlClause() : {} { ReserveClause() | OrganizationClause() | PaddingCharacterClause() | RecordDelimiterClause() | AccessModeClause() | AlternateRecordKeyClause() | FileStatusClause() | PasswordClause() } void SelectClause() : {} { ( FileName() [ ( | [ ] ) ] )+ | ( FileName() [ [ ] ] )+ | ( FileName() )+ | ( FileName() )+ )+ } /** * The "one-size-fits-all" statement of COBOL: it replaces for, while, call... */ void PerformStatement() : {} { ( PerformProcedureScopeClause() [ PerformFlavour() ] | PerformFlavour() ( StatementList() | PerformProcedureScopeClause() ) ) } void PerformFlavour() : {} { PerformTimeClause() | PerformUntilClause() | PerformVaryingWithTestClause() } void PerformVaryingWithTestClause() : {} { ( PerformTestPositionClause() PerformVaryingClause() | PerformVaryingClause() [ PerformTestPositionClause() ] ) } void PerformVaryingClause() : {} { QualifiedDataName() ( Identifier() | Literal() ) ( Identifier() | Literal() ) PerformUntilClause() } void PerformUntilClause() : {} { Condition() } void PerformTestPositionClause() : {} { [ ] ( | ) } void PerformProcedureScopeClause() : {} { ProcedureName() [ ( | ) ProcedureName() ] } void PerformTimeClause() : {} { ( QualifiedDataName() | IntegerConstant() ) } void ReadStatement() : {} { FileName() [ ] [ ] [ QualifiedDataName() ] [ [ ] QualifiedDataName() ] [ [ ] StatementList() ] [ [ ] StatementList() ] [ [ ] StatementList() ] [ [ ] StatementList() ] [ ] } void ReleaseStatement() : {} { RecordName() [ QualifiedDataName() ] } void ReturnStatement() : {} { FileName() [ ] [ QualifiedDataName() ] [ ] StatementList() [ [ ] StatementList() ] [ ] } void RewriteStatement() : {} { RecordName() [ QualifiedDataName() ] [ [ ] StatementList() ] [ [ ] StatementList() ] [ ] } void SearchStatement() : {} { [ ] QualifiedDataName() [ QualifiedDataName() ] [ [ ] StatementList() ] ( Condition() ( StatementList() | ) )+ [ ] } void SetStatement() : {} { QualifiedDataName() ( ( Identifier() | | | | | Literal() ) | ( | ) [ ] ( Identifier() | Literal() ) ) } void SortStatement() : {} { FileName() ( [ ] ( | ) [ ] ( QualifiedDataName() )+ )+ [ [ ] [ ] [ ] ] [ [ ] [ ] AlphabetName() ] ( ( FileName() )+ | [ ] ProcedureName() [ ( | ) ProcedureName() ] ) ( ( FileName() )+ | [ ] ProcedureName() [ ( | ) ProcedureName() ] ) } void StartStatement() : {} { FileName() [ [ ] ( [ ] | | [ ] | | [ ] | | [ ] [ ] | ) QualifiedDataName() ] [ [ ] StatementList() ] [ [ ] StatementList() ] [ ] } void StopStatement() : {} { ( | Literal() ) } void StringStatement() : {} { ( ( QualifiedDataName() | Literal() )+ [ ] ( Identifier() | Literal() | ) )+ Identifier() [ [ ] QualifiedDataName() ] [ [ ] StatementList() ] [ [ ] StatementList() ] [ ] } void SubtractStatement() : {} { ( ( Identifier() | Literal() )+ ( Identifier() [ ] )+ | ( Identifier() | Literal() ) Identifier() [ ] Identifier() | ( | ) QualifiedDataName() QualifiedDataName() ) [ [ ] StatementList() ] [ [ ] StatementList() ] [ ] } void UnstringStatement() : {} { QualifiedDataName() [ [ ] [ ] ( Identifier() | Literal() ) ( [ ] ( Identifier() | Literal() ) )* ] ( Identifier() [ [ ] Identifier() ] [ [ ] Identifier() ] )+ [ [ ] QualifiedDataName() ] [ [ ] QualifiedDataName() ] [ [ ] StatementList() ] [ [ ] StatementList() ] [ ] } void UseStatement() : {} { ( [ ] [ ] ( ( ProcedureName() )+ | ) | [ ] [ ] ( ( | ) | [ ( | ) ] [ ( | | ) ]