GithubHelp home page GithubHelp logo

Comments (4)

osmedile avatar osmedile commented on August 22, 2024

You can write identifiers and paragraphs that start with digits.

Page 9 of Cobol V5.1 reference:

A COBOL word is a character-string that forms a user-defined word, a
system-name, or a reserved word. The maximum size of a COBOL user-defined
word is 30 bytes. The number of characters that can be specified depends on the
code page indicated by the compile-time locale.
Except for arithmetic operators and relation characters, each character of a COBOL
word is selected from the following set:

  • Latin uppercase letters A through Z
  • Latin lowercase letters a through z
  • digits 0 through 9
  • - (hyphen)
  • _ (underscore)

The hyphen cannot appear as the first or last character in such words. The
underscore cannot appear as the first character in such words. Most user-defined
words (all except section-names, paragraph-names, priority-numbers, and
level-numbers) must contain at least one alphabetic character. Priority numbers and
level numbers need not be unique; a given specification of a priority-number or
level-number can be identical to any other priority-number or level-number.
In COBOL words (but not in the content of alphanumeric, DBCS, and national
literals), each lowercase single-byte alphabetic letter is considered to be equivalent
to its corresponding single-byte uppercase alphabetic letter.*

from typecobol.

smedilol avatar smedilol commented on August 22, 2024

As stated by Cobol reference:
The mantissa of a floating point always contains a decimal point (char '.' by default or char ',' if DECIMAL-POINT IS COMMA is specified).
So there's no confusion between a floating-point and a variable name.

Picture of a floating-point use almot the same syntax, except that char 'V' can replace the decimal point. The following picture clause are equivalent:

       01 floatingPoint  pic -9v9(9)E-99.
       01 floatingPoint2 pic -9.9(9)E-99.

I can then write the following paragraph:

       testFloatingPoint.
           compute floatingPoint = 2.3E-13 + -3.444E-1.

from typecobol.

laurentprudhon avatar laurentprudhon commented on August 22, 2024

In the current version, the Scanner has been implemented with an important goal in mind : to help the developers correct their spelling mistakes by giving them meaningful error messages.
In several situations, the Scanner recognizes an "almost correct" input : it can then continue analyzing the program, and output a nice error message : "you must correct this detail, but I think I have understood what you where trying to say".
For example, if a user enters the string 23E-2, the Scanner will recognize it as an attempt to input a floating point literal, but will print an error message saying that a period is mandatory in the mantissa and that the exponent must be on two chars, helping the user to correct his mistake 23.0E-02.
If we don't do this, 23E-2 will be recognized a user defined word, a strange error will occur in the Parser while trying to match an arithmetic expression, and the developer may have a hard time understandind what happened.
So I chose to preserve this behavior, and then I can not support user defined words of the form 23E--02.
We have a tradeoff to make here : to make a good decision, we must try to evaluate which one of the two situations will be more frequent / important for our developers.

from typecobol.

wiztigers avatar wiztigers commented on August 22, 2024

Identifier beginning with digits but that don't look like numeric literals are now properly recognized.
As the primary problem is solved, I'll close this issue.

Please continue discussing this topic in issue #65.

from typecobol.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.