Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax does not parse variable declarations like REAL A / 1.0 / #34

Open
lsafina opened this issue Apr 30, 2024 · 1 comment
Open

Syntax does not parse variable declarations like REAL A / 1.0 / #34

lsafina opened this issue Apr 30, 2024 · 1 comment

Comments

@lsafina
Copy link
Collaborator

lsafina commented Apr 30, 2024

Test:

        REAL  A / 1.0 /
        END

Syntax output:

        REAL  A / 1.0 /
	        ^
test/evref/real-declaration.FOR, line 1: column 17: Error:	"( %symbolic_name" is inserted before "/".

        REAL  A / 1.0 /
		  ^
test/evref/real-declaration.FOR, line 1: column 19: Error:	"1.0" is replaced by "%symbolic_name".

        REAL  A / 1.0 /
		       ^
test/evref/real-declaration.FOR, line 1: column 24: Error:	"%symbolic_name )" is inserted before "%EOL".

As a result wrong json:

{
    "tag": "fortran_file",
    "comments":
    {},
    "file": "test/evref/real-declaration.FOR",
    "program_units":
    [
        {
            "tag": "main",
            "name": "null",
            "prog_unit_parameters":
            [],
            "start_pos":
            {
                "line": "1",
                "column": "9"
            },
            "end_pos":
            {
                "line": "2",
                "column": "11"
            },
            "statement_list":
            [
                {
                    "tag": "variable_declaration_statement",
                    "start_pos":
                    {
                        "line": "1",
                        "column": "9"
                    },
                    "type":
                    {
                        "tag": "type_reference",
                        "start_pos":
                        {
                            "line": "1",
                            "column": "9"
                        },
                        "name": "REAL"
                    },
                    "declarators":
                    [
                        {
                            "tag": "variable_declarator",
                            "start_pos":
                            {
                                "line": "1",
                                "column": "15"
                            },
                            "variable":
                            {
                                "tag": "symbolic_name",
                                "start_pos":
                                {
                                    "line": "1",
                                    "column": "15"
                                },
                                "name": "A"
                            },
                            "dimension_declarators":
                            [
                                {
                                    "tag": "dimension_declarator",
                                    "start_pos":
                                    {
                                        "line": "1",
                                        "column": "17"
                                    },
                                    "upper_bound":
                                    {
                                        "tag": "binary_expression",
                                        "start_pos":
                                        {
                                            "line": "1",
                                            "column": "17"
                                        },
                                        "lhs":
                                        {
                                            "tag": "binary_expression",
                                            "start_pos":
                                            {
                                                "line": "1",
                                                "column": "17"
                                            },
                                            "lhs":
                                            {
                                                "tag": "variable_expression",
                                                "variable":
                                                {
                                                    "tag": "symbolic_name",
                                                    "start_pos":
                                                    {
                                                        "line": "1",
                                                        "column": "17"
                                                    },
                                                    "name": ""
                                                }
                                            },
                                            "operator":
                                            {
                                                "tag": "arithmetic_operator",
                                                "start_pos":
                                                {
                                                    "line": "1",
                                                    "column": "17"
                                                },
                                                "operator_value": "/"
                                            },
                                            "rhs":
                                            {
                                                "tag": "variable_expression",
                                                "variable":
                                                {
                                                    "tag": "symbolic_name",
                                                    "start_pos":
                                                    {
                                                        "line": "1",
                                                        "column": "19"
                                                    },
                                                    "name": ""
                                                }
                                            }
                                        },
                                        "operator":
                                        {
                                            "tag": "arithmetic_operator",
                                            "start_pos":
                                            {
                                                "line": "1",
                                                "column": "23"
                                            },
                                            "operator_value": "/"
                                        },
                                        "rhs":
                                        {
                                            "tag": "variable_expression",
                                            "variable":
                                            {
                                                "tag": "symbolic_name",
                                                "start_pos":
                                                {
                                                    "line": "1",
                                                    "column": "24"
                                                },
                                                "name": ""
                                            }
                                        }
                                    }
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ]
}
@lsafina
Copy link
Collaborator Author

lsafina commented Apr 30, 2024

Not clear if it is an extension or not.

Oracle writes: You can define a variable with an assignment statement, an input statement, or a DATA statement. If a variable is assigned a value in a DATA statement, then it is initially defined..

However, oracle uses examples with such initialisation in slashes everywhere without mentioning that it is an extension, e.g
https://docs.oracle.com/cd/E19957-01/805-4939/z40007437a27/index.html
https://docs.oracle.com/cd/E19957-01/805-4939/6j4m0vn6m/index.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant