-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
C grammar, standard C90 #3325
base: master
Are you sure you want to change the base?
C grammar, standard C90 #3325
Conversation
FuncCallwithVarArgs.c : FunctionReturningPointer.c pr403.c: |
although I made FunctionReturningPointer.c.errors
https://github.com/parstools/grammars-v4/actions/runs/4657790061/jobs/8242732094#step:18:45 |
Every single error message from the parser must end with a newline. You should use trgen to remaster your test files. I don't know why you left the bogus input in the file though. |
NB!! You placed an entirely new grammar for C in the same directory containing an existing grammar. They are not the same and it confuses everyone--and the build tool. The build tool can handle multiple grammars, but you have to program for the two, which you have to do with the desc.xml. At some point, there should be more recent versions of the C grammar based on scraping of the ISO Spec. So, it's best you start the directory structure right now. The build tool opens every grammar in the directory and parses it. It then looks for the grammar name and the start rule. There are two different grammar names and two start rules. Please create the following directory structure. c/ Place the existing files before your changes in c/c/. Place your new grammar in c/c90/. Add a desc.xml to c/c90/. Copy the c/c/examples/ to c/c90/examples. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git mv c/desc.xml c/C/desc.xml
. A copy of desc.xml is placed in the same directory as the .g4. (There should not be a desc.xml without a .g4; every directory that contains a .g4 needs a desc.xml.)cp c/C/desc.xml grammars-v4/c/C90/desc.xml
.- In
c/C/pom.xml
, change<packageName>c</packageName>
to<packageName></packageName>
. (mvn clean test
was failing.) - In
c/C90/pom.xml
, change<packageName>c90</packageName>
to<packageName></packageName>
. (mvn clean test
was failing.) - For the new C90 grammar, can we add the tests you used to validate the grammar? We may need to place those in another directory, like "c/C90/validation-large/" (or whatever you think). We can then validate the grammar against this for Java and CSharp since the other targets may be too slow.
By the way, excellent work. Thank you for adding this grammar!
How large can be test grammar? place preprocessed file or not preprocessed
with shell script calling preprocess?
wt., 11 kwi 2023 o 11:15 Ken Domino ***@***.***> napisał(a):
… ***@***.**** requested changes on this pull request.
- For the new C90 grammar, can we add the tests you used to validate
the grammar? We may need to place those in another directory, like
"c/C90/validation-large/" (or whatever you think). We can then validate the
grammar against this for Java and CSharp since the other targets may be too
slow.
Message ID: ***@***.***>
|
This looks good @borneq I tested out the grammar with all the targets, and it looks like Cpp, CSharp, Dart, Java all parse fast. The Go target works fast too, but only on the most recent dev fixes, which we're not testing yet. But, of the targets mentioned, all take 3-6 s. Dart is the fastest at 3s, CSharp and Java slowest of these 5 targets. (My machine a standard AMD Ryzen 7 2700, 16G DDR4 1311 MHz, SSD, B450 motherboard. Single test from command-line, i.e., not a statistical analysis.) @borneq Let's add in two test scenarios, one for short tests that all targets can pass, and the longer test scenario for the "fast" targets. Please update the c/C90/desc.xml file as follows:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@teverett This PR is looks good.
…nd statement; simplification and fix - example
It is many GCC extension, is not pure C90. Maybe rename C90 to GCC90 and later add second grammar C90 or IsoC90 with removing extensions. (GCC compile with -pedantic-errors) Will 2x faster if remove K&R style function definitions, but ISO C90 don't parse validation-large/std90.c and other preprocessed GCC includes. |
I will correct typeName: simple generator od type name generates enormous deep lookahead |
I change intTypeName to can be any combinations of components
floatTypeName is specified
If I test file
I obtain unlimited maximal k for lookahead. I found two problems:
|
…lone to be unambiguous to intTypeName
…reasing huge lookahead depth removed cdecl
Syntax distinguish between variable and function declaration, speedup. |
disambiguation, speedup twice on test file |
Simple expressions like "n = 0" have deep expression chain, depth 20. |
Is possible solve conflict by me and synchronize repositories or I must close this and create new pull request? |
C Grammar , old C90 standard, tested on 216 includes standard library , mainly from /usr/include, some from /usr/include/x86_64-linux-gnu/bits. Only these headers, which not caused error when GCC was called with "-std=c90 -fsyntax-only -E" to file /dev/shm/file.c, next parsed with Antr4 and C++ runtime.
C99, C11, C17 can be created incrementally, and could be tested on big C repositories.