Add Simula - #8137
Conversation
There was a problem hiding this comment.
We do not need so many samples, especially those that are not real world examples of the language. Please cut down the samples to only real examples and update the PR template to point to the exact sources.
Additionally, your search results indicate usage doesn't meet our requirements yet, but the inverse does… ie there are significantly more .sim files that do not match your search than do. This means they'll all be misidentified. To prevent this, you will also need to identity the most common user of that extension and add support as part of the PR with heuristics to differentiate the two languages.
|
i have finally addressed this now. i cut the sample set down to real-world examples and updated the template with the exact sources. i also moved i checked the final rules against 677 live |
lildude
left a comment
There was a problem hiding this comment.
If you're going to go the generic route, we only need samples for the language you're adding. I'm not sure we need such a complex heuristic either. Several of your regexes are also vulnerable to ReDoS attack.
Several of your Simula samples still look like tutorial type illustrations of features of the language and not real-world code.
|
Thanks, I've pared this down quite a bit. The generic fixture set now only contains two sourced Simula programs. I removed the unrelated .sim fixtures and the tutorial-style samples, and replaced the heuristic with two simple linear patterns. The full test suite passes. Could you take another look when you have a chance? |
| def test_sim_by_heuristics | ||
| simula = Dir.glob("#{fixtures_path}/Generic/sim/Simula/*") | ||
|
|
||
| assert Strategy::Extension.generic?("example.sim") | ||
| assert_heuristics({ | ||
| "Simula" => simula | ||
| }) | ||
| simula.each do |blob| | ||
| assert_equal Language["Simula"], Linguist.detect(file_blob(blob)), "Failed full detection for #{blob}" | ||
| end | ||
| end |
There was a problem hiding this comment.
This is over-engineered. Use the same approach as other generic language tests, like test_sol_by_heuristics.
adds simula support to linguist, including syntax highlighting,
.simdetection, samples, and a language color.description
this adds simula as a language in linguist.
the grammar covers simula 67 and newer simula-style syntax. free simula is covered as a dialect of simula rather than being added as a separate language.
.simis used by quite a few unrelated formats, so it is now registered as a generic extension and identified using content heuristics instead of being mapped directly to simula.while testing the heuristics against real
.simfiles i found two actual false-positive cases.mcstas/mccode result files can contain
simulationand a laterbeginon separate lines, which an earlier\s+pattern treated like simula'sSimulation Begin. that signature now requires them to be on the same line.pascal files can also use the same basic
PROGRAM name; BEGINshape. that rule now requires additional simula-specific syntax before it can classify the file as simula.i checked the final rules against 677
.simfiles from github. 439 were simula sources and 425 were detected. none of the 238 non-simula files in the set were classified as simula.the 14 missed simula files are old classless programs without enough distinctive syntax to separate them safely from unrelated
.simfiles. matching those would mean bringing back much broaderbegin+ declaration patterns, so i left them unmatched rather than increasing false positives.the full linguist test suite passes:
the simula heuristic test also passes with 78 assertions.
checklist
i am adding a new language.
the extension is used in real simula projects on github.
usage search:
i have included real-world samples and linked them to their exact sources.
GNU CIM
simset.simfree simula sources
add the exact source URLs for the remaining retained real-world samples here after trimming the sample set
i have included a syntax highlighting grammar:
i have added a color:
#4f78a8i am adding new or changing current functionality
.simis included in the generic extensions and differentiated using heuristics