Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Compilers

Name: Anonymous 2016-10-04 22:08

Is the most important part of a compiler the lexer, or the parser?

Name: Anonymous 2016-10-04 22:17

No

Name: Anonymous 2016-10-05 0:59

The result is often thousands of needless lines of code passing through the lexical analyzer, which is (in good compilers) the most expensive phase.

-rob pike

Name: Fringe 2016-10-05 2:06

Name: Anonymous 2016-10-05 2:48

>>3
thousands of needless lines
Can't you write a lexer for a C-ish language in less than, say, 500 lines of C?

Name: Anonymous 2016-10-05 5:21

>>5
You can write literally anything in less than 500 lines of C.

Name: Anonymous 2016-10-05 10:34

>>6
How do you explain this then?

http://bbs.progrider.org/prog/read/1475347547

So 300 lines of Perl worth 1700 lines of Haskell and 30.000 lines of C?

Name: Anonymous 2016-10-05 10:49

>>1

the most important part of the compiler is the production of optimized assembly for the target architecture, which propagates through the four last stages (AST, SSA, link-time and JIT optimizations). Because if speed is unimportant, you can just use an interpreter.

Name: Anonymous 2016-10-05 10:57

The most important part of the compiler is the type-checker for your dependently-typed type system.

Have you read your TAPL today?

Name: Anonymous 2016-10-05 14:10

>>9

type-checker is othogonal to compiler. I.e. you can statically analyze program without compiling it to any executable form. On the other hand, you can have compiler without type-checking.

Name: Anonymous 2016-10-05 16:16

>>10
Lexer is orthogonal to compiler. I.e. you can lexically analyze program without compiling it to any executable form. On the other hand, you can have compiler without lexical analysis (see e.g. here https://en.wikipedia.org/wiki/Whitespace_(programming_language : all the tokens in this language are 1 symbol long, and whitespaces don't need to, and in fact should never, be stripped -- thus this language requires no lexer).

Name: Anonymous 2016-10-05 16:22

>>10
Type information can be used in optimizations, error messaging and code generation (as in C++ templates), so how can type-checking be orthogonal to compilation?

Name: Anonymous 2016-10-05 18:04

>>12
the backend of GHC is untyped

Name: Anonymous 2016-10-05 20:07

>>13
No, it's not.

Core is a very small, explicitly-typed, variant of System F. The exact variant is called System FC, which embodies equality constraints and coercions.

https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/CoreSynType

Name: Anonymous 2016-10-05 22:15

>>14
nah its untyped past that. dont post bad comments

Name: Anonymous 2016-10-06 7:21

>>15
No, it's not "untyped past that". You havf been posting misinformation.

Before code generation, GHC converts the Core-language program into StgSyn
Types have largely been discarded, retaining only enough type information as is needed to guide code generation
https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/StgSynType

As you can see, types are definitely necessary for code generation. Thus the type checker is absolutely not orthogonal to the compiler.

Name: Cudder !cXCudderUE 2016-10-06 11:25

>>5
Here's a C subset interpreter in less than 500 SLoC:
https://github.com/rswier/c4/blob/master/c4.c

Contains lexer, parser, code generator, and stack-based VM interpreter.

But the most important part is the optimiser/instruction generator. All these toy interpreters/compilers generate horrible code because they didn't think of code generation too much.

Name: Anonymous 2016-10-06 11:46

Action instead of talk?

Name: Anonymous 2016-10-06 16:55

>>17
Kys tripfag.

Sent from my iPhone using Tapatalk.

Name: L. A. Calculus !jYCj6s4P.g 2016-10-07 7:54

>>17

c4.c:76:39: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
./a.out hello.c
Segmentation fault

GJ. ONCE A STAK BOI RETOID ALWAYS A STAK BOI RETOID.

Name: suigin 2016-10-07 8:22

What happens when a star with more than 10 solar masses runs out of fuel and succumbs to gravitational collapse.

Name: Cudder !cXCudderUE 2016-10-07 10:42

>>20
Use a real system where pointers and integers are the same size.

Name: Anonymous 2016-10-07 12:33

>>22
Nice dubs, but it's a bad idea to write code that depends on implementation specifics. At least include some kind of assertion that sizeof(int) == sizeof(void *) causing it to either fail to compile or to exit early at runtime if the sizes aren't equal.

Name: Anonymous 2016-10-07 13:55

>>20,22
this is the beginning of the greatest battle in the history of /prague/

Name: Anonymous 2016-10-07 14:51

>>21
Ten solar masses, that is not a lot, I guess it would go into a helium cycle and then blow its outer shell out during the helium flash. It would become a red supergiant giant. B, Eventually it will lose its outer shell and become a white dwarf.
It won't go nova, because its core never get hot enough to fuse carbon to neon and neon to iron.( Although some do go nova, not sure what the mechanism is there).

Name: Anonymous 2016-10-07 14:55

>>23
Give the guy a break. It's a bare bones C interpreter and pretty cool.

Name: Anonymous 2016-10-07 15:00

>>23
It is a proof of concept, not a industrial strength compiler. It shows it is possible to interpret c within certain constraints.

Don't change these.
Name: Email:
Entire Thread Thread List