azdavis / millet

A language server for Standard ML.
https://azdavis.net/posts/millet
Apache License 2.0
210 stars 12 forks source link

Added basic support for ML-Lex and ML-Yacc files to CM file parser #60

Closed csb6 closed 3 months ago

csb6 commented 3 months ago

Description

The parser for CM files has been extended to handle ML-Lex and ML-Yacc specification files and add their generated files to the library sources.

Motivation

ML-Lex and ML-Yacc are SML/NJ's standard lexer and parser generators, respectively, and so have special integration with the CM build system. For source files with the extension ".l" or ".lex", CM automatically runs ML-Lex, which generates a file with the same filename as the ".lex" file with an additional ".sml" extension at the end. For files with ".y" or ".grm" extensions, CM runs ML-Yacc, generating both a ".sig" and ".sml" file in a similar way. All of the generated files are then treated as if they were explicitly listed in the .cm file and regenerated as needed.

Before this change, Millet showed an error ("unknown class") in CM files containing filenames with these extensions. Since the generated files were not being added to Millet's list of source files, completion and other analysis wasn't being done for these files. This limited my ability to use Millet with ML-Yacc and ML-Lex.

Tests

I have added tests to show that Millet can now parse CM files containing filenames with these extensions. I was not able to find existing tests that verify what actually ends up being added to Millet's sources list after parsing so I did not add any to verify that the generated files are added properly, but I may have missed them.