Skip to content

Line directive has optional filename argument.#266

Open
TIMONz1535 wants to merge 1 commit into
tgjones:masterfrom
TIMONz1535:fix_line_directive
Open

Line directive has optional filename argument.#266
TIMONz1535 wants to merge 1 commit into
tgjones:masterfrom
TIMONz1535:fix_line_directive

Conversation

@TIMONz1535
Copy link
Copy Markdown

  • Filename string argument in the line directive is optional https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-appendix-pre-line
  • If this happens then in ParseLineDirective I create the missing token EndOfDirectiveToken. I'm not sure if its ok, but it works.
  • HlslLexer.LexDirectiveToken must reset his value _value = null; before parsing, like HlslLexer.LexSyntaxToken. Because some directives have no value and it extrapolates the previous one to next - bad.
  • Removing afterLineNumber argument from ParseEndOfDirective. It looks like a special error for the line directive, it referred to MissingPreprocessorFile but was never used.
  • Added a test for #line without filename, it also checking if the end of directive is parsed correctly.
  • Fix test checking for LineDirectiveTrivia kind. No more special cases for 0, -1, -2 line number. It just should be >= 0. Yes, correlates with the latest DXC release!
#line 10 "file.hlsl"  // valid
#line 20              // valid too

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

Successfully merging this pull request may close these issues.

1 participant