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

Dimensions? #6

Open
rebcabin opened this issue Oct 4, 2022 · 2 comments
Open

Dimensions? #6

rebcabin opened this issue Oct 4, 2022 · 2 comments

Comments

@rebcabin
Copy link

rebcabin commented Oct 4, 2022

I noticed that while dimension is spec'ced as follows

dimension = (expr? start, expr? length)

concrete examples of dimension print out as in the following

(Integer 4 [2 3] [4]) # a ttype for an array of 4-byte ints; 
# [2 3] and [4] are of ASDL type "dimension"

instead of as

(Integer 4 [(IntegerConstant 2 (Integer 4 [])) (IntegerConstant 3 (Integer 4[]))] 
           [(IntegerConstant 4 (Integer 4 []))])

This is surprising because 2, 3, and 4 in [2 3] [4] are not exprs.

Is this just shorthand in the printout? Is the long-form acceptable input to ASR processors?

@certik
Copy link
Contributor

certik commented Oct 4, 2022

Can you give an example? I can't reproduce it. The following Fortran code:

integer :: x(2:4, 3)

Prints as:

                            x:
                                (Variable 
                                    2 
                                    x 
                                    Local 
                                    () 
                                    () 
                                    Default 
                                    (Integer 4 [((IntegerConstant 2 (Integer 4 [])) 
                                    (IntegerConstant 3 (Integer 4 [])))
                                    ((IntegerConstant 1 (Integer 4 [])) 
                                    (IntegerConstant 3 (Integer 4 [])))]) 
                                    Source 
                                    Public 
                                    Required 
                                    .false.
                                )

Which already seems exactly in the form that you want.

Is the long-form acceptable input to ASR processors?

Yes, I would recommend to only use long form. We use short form in AST, but it doesn't seem worth it, because one looks at it infrequently, and when one does look at it, it's better to use longform so that one knows exactly what nodes are in there.

@rebcabin
Copy link
Author

rebcabin commented Oct 5, 2022

Investigating ... I thought I saw this in one of the LPython xxx.stdout examples.

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

2 participants