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

Larger Max numerical suffix/idx for the DSL Methods #802

Closed
fengliner opened this issue Aug 10, 2018 · 5 comments
Closed

Larger Max numerical suffix/idx for the DSL Methods #802

fengliner opened this issue Aug 10, 2018 · 5 comments

Comments

@fengliner
Copy link

fengliner commented Aug 10, 2018

09-2019 Update

This is now possible as Chevrotain no longer depends on Function.prototype.toString

The following DSL methods have been added in version 6.4.0 which accept an idx argument.

There are no respective _sep variations as the _SEP dsl methods are likely to be re-implemented
as macros in the future rather than a base "building block".

The maximum valid idx is 255, this is validated during grammar recording, an invalid value
will cause an error to be thrown during parser initialization.


Original Issue

What is max numerical suffix for the DSL Rules?Is 9?
What can I do if numerical suffix more than 9?

@fengliner fengliner changed the title max Max numerical suffix for the DSL Rules Aug 10, 2018
@bd82
Copy link
Member

bd82 commented Aug 10, 2018

Do you have a real example where you needed more than 9 suffix?

The suffixes are part of the "identity" of the specific DSL rule,
What this means is that as long as the identity is unique you don't need a unique suffix,
For example

$.RULE("myRule", () => {
  // we dont need any suffixes here because the "Identity" also uses the Token Name...
  $.CONSUME(A)
  $.CONSUME(B)
  $.CONSUME(C)
  $.CONSUME(D)
  $.CONSUME(E)
)

What can I do if numerical suffix more than 9?

@fengliner
Copy link
Author

More than 9 suffix is normal to mysql grammar. Example, the tableOption rule, option suffix is more than 9.

tableOption:
ENGINE '='? engineName
| AUTO_INCREMENT '='? decimalLiteral
| AVG_ROW_LENGTH '='? decimalLiteral
| DEFAULT? (CHARACTER SET | CHARSET) '='? charsetName
| CHECKSUM '='? boolValue = ('0' | '1')
| DEFAULT? COLLATE '='? collationName
| COMMENT '='? STRING_LITERAL
| COMPRESSION '='? STRING_LITERAL
| CONNECTION '='? STRING_LITERAL
| DATA DIRECTORY '='? STRING_LITERAL
| DELAY_KEY_WRITE '='? boolValue = ('0' | '1')
| ENCRYPTION '='? STRING_LITERAL
| INDEX DIRECTORY '='? STRING_LITERAL
| INSERT_METHOD '='? insertMethod = (NO | FIRST | LAST)
| KEY_BLOCK_SIZE '='? fileSizeLiteral
| MAX_ROWS '='? decimalLiteral
| MIN_ROWS '='? decimalLiteral
| PACK_KEYS '='? extBoolValue = ('0' | '1' | DEFAULT)
| PASSWORD '='? STRING_LITERAL
| ROW_FORMAT '='? rowFormat = (
DEFAULT
| DYNAMIC
| FIXED
| COMPRESSED
| REDUNDANT
| COMPACT
)
| STATS_AUTO_RECALC '='? extBoolValue = (DEFAULT | '0' | '1')
| STATS_PERSISTENT '='? extBoolValue = (DEFAULT | '0' | '1')
| TABLESPACE uid tablespaceStorage?
| UNION '='? '(' tables ')';

@bd82
Copy link
Member

bd82 commented Aug 13, 2018

Thanks for the example.

Personally I would not translate such a rule "directly" without changes.

  • Option1: each one of the alternative could get its own nested rule.
    • This would enable better seperation for the semantics (e.g AST Building logic).
  • Option2: Factor out the common left hand prefix and examine if the value on the right hand side is of the correct "type" in a post processing phase.
    •      tableOption:
              tableOptKey '='? tableOptValue
              |  TABLESPACE uid tablespaceStorage?
           ;
      
    • That would simplify the grammar, but add some complexity at a later phase.

Either of the options would avoid the need for really large suffixes.
Additionally there is an internal limitation that limits a suffix to 4bits (value 15).
Anything more could lead to unexpected errors due to the creation of invalid cache keys.

@bd82
Copy link
Member

bd82 commented Aug 13, 2018

Closing this, please re-open if needed.

@bd82 bd82 closed this as completed Aug 13, 2018
@bd82
Copy link
Member

bd82 commented Sep 14, 2019

Re-opening as this is now possible.

@bd82 bd82 reopened this Sep 14, 2019
@bd82 bd82 changed the title Max numerical suffix for the DSL Rules Larger Max numerical suffix/argument for the DSL Rules Sep 14, 2019
@bd82 bd82 changed the title Larger Max numerical suffix/argument for the DSL Rules Larger Max numerical suffix/argument for the DSL Methods Sep 14, 2019
@bd82 bd82 changed the title Larger Max numerical suffix/argument for the DSL Methods Larger Max numerical suffix/idx for the DSL Methods Sep 14, 2019
@bd82 bd82 closed this as completed Sep 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants