Skip to contentSkip to conversation

Parser

DISCUSSION Kevin Lacquement 4 participants 6 messages Mar 4, 2009 – Mar 9, 2009

lore
Share & tools
lore
#0 lore raw

Again looking at the script parser, I notices that it uses a Yacc-generated parser, but a hand-written tokenizer. Is there a reason that it doesn't use Lex? Is it due to external dependencies, and if so, is there a way to recreate these deps (library or whatever) within the constraints of the bootloader?

Signature · 1 line
Sic non confunctus, non reficiat.
#1 lore raw
Quoted 5 lines · Kevin Lacquement

Again looking at the script parser, I notices that it uses a Yacc-generated parser, but a hand-written tokenizer. Is there a reason that it doesn't use Lex? Is it due to external dependencies, and if so, is there a way to recreate these deps (library or whatever) within the constraints of the bootloader?

Right, and I really hate the handwritten parser. It is easy to cleanly use bison. Lex, OTOH, isn't easy and clean to use. IIRC it depended on file IO, etc. If you know a *clean* way to deal with this, I would favor it. Making all kinds of dirty stubs is something I don't really like.

--
Marco

#2 lore raw
Quoted 8 lines · Marco Gerards
Quoted 5 lines · Kevin Lacquement

Again looking at the script parser, I notices that it uses a Yacc-generated parser, but a hand-written tokenizer. Is there a reason that it doesn't use Lex? Is it due to external dependencies, and if so, is there a way to recreate these deps (library or whatever) within the constraints of the bootloader?

Quoted 6 lines

Right, and I really hate the handwritten parser. It is easy to cleanly use bison. Lex, OTOH, isn't easy and clean to use. IIRC it depended on file IO, etc. If you know a *clean* way to deal with this, I would favor it. Making all kinds of dirty stubs is something I don't really like.

I've looked at flex (including its source), and it looks like the standard library #includes are hardcoded in. I'm going to look into some alternatives to allow the lexer to be created cleanly without adding too much of a burden to other developers in the way of project deps.

Alternatively, is there a clean, portable way to make the C compiler think that the grub headers are actually the system headers? Or possibly to replace the system header calls in the generated C code? (Using sed or something similar)

Signature · 1 line
Sic non confunctus, non reficiat.
#3 lore raw

Am Montag, den 09.03.2009, 09:43 -0700 schrieb Kevin Lacquement:

Quoted 5 lines

Alternatively, is there a clean, portable way to make the C compiler think that the grub headers are actually the system headers? Or possibly to replace the system header calls in the generated C code? (Using sed or something similar)

gcc has -nostdinc to remove the standard search paths for the includes.

http://gcc.gnu.org/onlinedocs/gcc-4.3.3/gcc/Preprocessor-Options.html#Preprocessor-Options

Signature · 1 line
Felix Zielcke
#4 lore raw
Quoted 8 lines · Felix Zielcke

Am Montag, den 09.03.2009, 09:43 -0700 schrieb Kevin Lacquement:

Quoted 5 lines

Alternatively, is there a clean, portable way to make the C compiler think that the grub headers are actually the system headers? Or possibly to replace the system header calls in the generated C code? (Using sed or something similar)

Quoted 4 lines

gcc has -nostdinc to remove the standard search paths for the includes.

http://gcc.gnu.org/onlinedocs/gcc-4.3.3/gcc/Preprocessor-Options.html#Preprocessor-Options

If we do that, though, we'll still need to create wrapper headers for the headers that flex #includes. Also, does grub depend on gcc, or will it work with other C compilers? I'd like to avoid adding a dependency on a specific compiler if the dep doesn't already exist.

Signature · 1 line
Sic non confunctus, non reficiat.
#5 lore raw

From: Kevin Lacquement <[email protected]>
Date: Mon, 09 Mar 2009 12:03:14 -0700

Quoted 4 lines

If we do that, though, we'll still need to create wrapper headers for the headers that flex #includes. Also, does grub depend on gcc, or will it work with other C compilers? I'd like to avoid adding a dependency on a specific compiler if the dep doesn't already exist.

Such a dependency already exists, to be honest.

From GCC extensions such as type and function attributes to exporting libgcc internal symbols, there is a hard dependency on GCC and I doubt that's going away any time soon.