Giter VIP home page Giter VIP logo

Comments (5)

rdb avatar rdb commented on May 30, 2024

Thanks for sharing, that's pretty cool!

Is there an action point you are suggesting for us here? Is there an advantage for us to replace the right recursion with left recursion as you have done? I'm a bit out of my depth with yacc/bison stuff.

from panda3d.

mingodad avatar mingodad commented on May 30, 2024

For LALR parser left recursion is preferable for less stack usage see here https://www.gnu.org/software/bison/manual/bison.html#Recursion and for my playground that automatically produce a parse tree left recursion produces shallow trees (easier to visualize without vertical scroll), but In some places when I've tried to replace then a lot of conflicts appeared so I only did in the ones that didn't generated conflicts for now.

After all of the latest fixes and continuing trying to parse sqlite3.c I found one syntax omission:

cppparser-nb -v -D__PANDA_CC__ -D__builtin_va_list=void* -Dwchar_t=pccwchar_t -S/usr/include -S/usr/lib/gcc/x86_64-linux-gnu/9/include sqlite3.c
Predefining __PANDA_CC__ as 
Predefining __builtin_va_list as void*
Predefining wchar_t as pccwchar_t
Reading sqlite3.c
...
 sqlite3.c:35320:24: error: syntax error, unexpected KW_VOLATILE
  static void dekkerMul2(volatile double *x, double y, double yy){
                         ^~~~~~~~
Error in parsing.

And experimenting in the playground (https://mingodad.github.io/parsertl-playground/playground/) I came with this possible fix:

--- <unnamed>
+++ <unnamed>
@@ -294,10 +294,14 @@
 
 optional_attributes :
 	%empty
-	| optional_attributes ATTR_LEFT attribute_specifiers ATTR_RIGHT
-	| optional_attributes ATTR_LEFT KW_USING name ':' /*4R*/ attribute_specifiers ATTR_RIGHT
-	| optional_attributes KW_ALIGNAS '(' /*20L*/ const_expr ')'
-	| optional_attributes KW_ALIGNAS '(' /*20L*/ type_decl ')'
+	| attributes
+	;
+
+attributes :
+	attributes ATTR_LEFT attribute_specifiers ATTR_RIGHT
+	| attributes ATTR_LEFT KW_USING name ':' /*4R*/ attribute_specifiers ATTR_RIGHT
+	| attributes KW_ALIGNAS '(' /*20L*/ const_expr ')'
+	| attributes KW_ALIGNAS '(' /*20L*/ type_decl ')'
 	;
 
 attribute_specifiers :
@@ -553,13 +557,20 @@
 	;
 
 function_parameter :
-	optional_attributes type formal_parameter_identifier maybe_initialize
-	| optional_attributes KW_CONST type formal_parameter_identifier maybe_initialize
-	| optional_attributes KW_CONST KW_REGISTER type formal_parameter_identifier maybe_initialize
-	| optional_attributes type_pack parameter_pack_identifier maybe_initialize
-	| optional_attributes KW_CONST type_pack parameter_pack_identifier maybe_initialize
-	| optional_attributes KW_CONST KW_REGISTER type_pack parameter_pack_identifier maybe_initialize
-	| optional_attributes KW_REGISTER function_parameter
+	optional_attributes type_qualifier_list type formal_parameter_identifier maybe_initialize
+	| optional_attributes type_qualifier_list type_pack parameter_pack_identifier maybe_initialize
+	| function_parameter attributes
+	;
+
+type_qualifier_list :
+    %empty
+	| type_qualifier_list type_qualifier
+	;
+
+type_qualifier :
+	KW_CONST
+	| KW_REGISTER
+	| KW_VOLATILE
 	;
 
 formal_parameter :

The above fix works on the playground and now when I looked at cppBison.yy to try it there I found that it's not using named references (it's using $0-9) and I'll try to convert it to named references first and probably propose it here.

from panda3d.

mingodad avatar mingodad commented on May 30, 2024

Here is the first working conversion from numeric references to named references using a script and manually fixing it.
Any feedback is welcome !

cppBison-dad.yxx.zip

from panda3d.

rdb avatar rdb commented on May 30, 2024

I appreciate the effort.

That said, it doesn't seem that this works with the bison 2.3 that ships with XCode. Are named references a more recent feature?

I am a bit reluctant to drop support for bison 2.3. I suppose we could require macOS users to install from homebrew, or have them use the pre-built file, but there have to be some compelling benefits.

from panda3d.

mingodad avatar mingodad commented on May 30, 2024

Yes that's a known problem, named references need a newer bison 2.5 (2011-05-14).

from panda3d.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.