Skip to content
New issue

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

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

Already on GitHub? # to your account

Return information about when state errored #335

Closed
domluna opened this issue May 2, 2022 · 2 comments
Closed

Return information about when state errored #335

domluna opened this issue May 2, 2022 · 2 comments

Comments

@domluna
Copy link

domluna commented May 2, 2022

Right now it seems the position at which a parsing error occurred is not kept.

julia> x
  1:353 file
  1:353  function
  1:174     1:2   OP: ::
  1:161    call
  1:13      arraycopy_rev
 14:39        1:2   OP: ::
 14:14       B
 15:37         1:1   OP: .
 15:22          1:1   OP: .
 15:18         LLVM
 19:21         quotenode
 19:21          API
 23:36        quotenode
 23:36         LLVMBuilderRef
 40:68        1:2   OP: ::
 40:45       OrigCI
 46:66         1:1   OP: .
 46:53          1:1   OP: .
 46:49         LLVM
 50:52         quotenode
 50:52          API
 54:65        quotenode
 54:65         LLVMValueRef
 69:102       1:2   OP: ::
 69:74       gutils
 75:100        1:1   OP: .
 75:77        API
 78:99        quotenode
 78:99         EnzymeGradientUtilsRef
103:129       1:2   OP: ::
103:106      tape
107:127        1:1   OP: .
107:114         1:1   OP: .
107:110        LLVM
111:113        quotenode
111:113         API
115:126       quotenode
115:126        LLVMValueRef
162:172    Cvoid
175:340   block
175:211      1:2   OP: =
175:179     orig
180:209     call
180:195        1:1   OP: .
180:183       LLVM
184:194       quotenode
184:194        Instruction
196:201      OrigCI
212:246      1:2   OP: =
212:219     origops
220:244     call
220:232        1:1   OP: .
220:223       LLVM
224:231       quotenode
224:231        operands
233:236      orig
247:340    errortoken
247:325     call
247:262      arraycopy_common
263:267      FALSE: false
268:282      call
268:279         1:1   OP: .
268:271        LLVM
272:278        quotenode
272:278         Builder
280:280       B
283:286      orig
287:296      ref
287:293       origops
294:294       INTEGER: 1
297:302      gutils
326:340     return
326:333      nothing

so

247:340    errortoken

is what I care about but if I inspect the parse state

julia> _, ps = CSTParser.parse(CSTParser.ParseState(text), true)

The last token is always at the end of the text and I can't find anything in the parse state that reflects the position at which the error occurred.

@pfitzseb
Copy link
Member

pfitzseb commented May 3, 2022

Any reason not to just iterate over the CST and find the errortoken position that way?

@pfitzseb
Copy link
Member

I'll just say this is by design and you should inspect the CST to find errortokens.

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

No branches or pull requests

2 participants