hydroper commented on issue #189:
URL: 
https://github.com/apache/royale-compiler/issues/189#issuecomment-1819309172

   Not a solution, but in my handwritten parser I did not create tokens with 
ASDoc comments, since comments are contributed to a `Source`'s comment 
collection before scanning a token:
   
   * Leading comments before a token are contributed to the `Source` while the 
tokenizer executes (in the same loop that ignores whitespace)
     * 
[tokenizer.consume_comment](https://github.com/hydroper/as3parser/blob/master/crates/as3_parser/src/tokenizer.rs#L514C5-L514C5)
   * 
[comment.is_asdoc(location_to_precede)](https://github.com/hydroper/as3parser/blob/master/crates/as3_parser/src/comment.rs#L44)
   
   Then, before parsing annotatable directives that may start with:
   
   * a meta data compatible expression (`[...]`, `[...][...]`)
   * `class`, `interface`, `function`, `var`, `const`
   * `public`, `private`, `protected`, `internal`
   * Identifier followed by identifier (each being possibly an attribute or one 
of (`enum`, `namespace`, `type`)
   
   I call a function `self.parse_asdoc()` which takes the last contributed 
comment and tests `comment.is_asdoc(location_to_precede)`, where 
`location_to_precede` is usually the offending token's location, returning 
`Option<ast::AsDoc>`.
   
   Example:
   
   ```rust
   if self.peek_annotatable_definition_reserved_word() {
       let asdoc = self.parse_asdoc()?;
       return self.parse_annotatable_definition(AnnotatableContext {
           start,
           metadata_exp: vec![],
           asdoc,
           first_modifier: None,
           previous_token_is_definition_keyword: false,
           context,
       });
   }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@royale.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to