Anyone ever write a compiler in LabVIEW 
Author Message
 Anyone ever write a compiler in LabVIEW

I am looking for anything anyone has done along the lines of writing a
compiler in labview.  I have no experience writing a compiler, and
would like to know if it can be done with LabVIEW.

My goal is to create MS Executable files to perform simple tasks.

Thank you,

Mike Du'Lyea



Sat, 25 Dec 2004 12:22:29 GMT  
 Anyone ever write a compiler in LabVIEW


Quote:
> I am looking for anything anyone has done along the lines of writing a
> compiler in LabVIEW.  I have no experience writing a compiler, and
> would like to know if it can be done with LabVIEW.

> My goal is to create MS Executable files to perform simple tasks.

> Thank you,

> Mike Du'Lyea

This is part of the higher developers kit (professional, maybe?).  You can
compile your vi's, and run them on any computer that runs the free runtime
engine.

I think the compiler is available stand-alone.  It's expensive, but way
cheaper than writing your own compiler.

Scott



Sat, 25 Dec 2004 20:16:21 GMT  
 Anyone ever write a compiler in LabVIEW

Quote:
> I am looking for anything anyone has done along the lines of writing a
> compiler in LabVIEW.  I have no experience writing a compiler, and
> would like to know if it can be done with LabVIEW.

> My goal is to create MS Executable files to perform simple tasks.

If you want to creat executables from the VI source, then the app
builder will save you anywhere from 2 to 100 man years.

If you are looking to write a compiler for another language, like a
script, then I don't know of anyone that has gone all the way, but
others have done similar things.

The Math VIs in vi.lib have a formula parser, and several users have
written similar ones.  This isn't a full compiler, but it is a
significant portion.  The parser takes apart the text and produces an
encoded form that represents the same expression.  The formula parser
builds up an expression tree so that it can more quickly compute it at
runtime.  If you want to produce a byte code, a C or assembly file to
pass off to another compiler, or object code, it is all doable if you
have enough patience.

Just to point out another clever set of VIs that is similar, the RoboLab
VIs start with a sequence of VIs that represent high level language
blocks.  At runtime, it accumulates them and builds a string which is
the encoded form that can be handed off to the brick.  Others have done
similar things for other diagram types like flowcharts or SFC diagrams.

Greg McKaskle



Sat, 25 Dec 2004 21:31:52 GMT  
 Anyone ever write a compiler in LabVIEW
Scott,

I know about the app builder, which is why I am asking about the
compiler.  I wanted to find out if anyone has written a compiler IN
LabVIEW to create object code, such as assembly.  The application
builder does not serve my purposes.

Thanks



Sat, 25 Dec 2004 23:40:47 GMT  
 Anyone ever write a compiler in LabVIEW
Greg,

I appreciate the input.

I have done some research on compilers, and I believe that it can be
done, and probably a bit easier than it could be with other languages.

Unfortunately, writing a compiler, even a simple one, is no easy task.

What I am trying to do here is take a short cut, and build upon the
work of someone who has written any kind of compiler for anything.

Practical application of a compiler built in LabVIEW is immense,
although a bit redundant for people that already know C/C++ and
Assembly.  A few examples of very useful applications of a compiler:

Very easy programming of embedded controllers in native language (or
assembly) with compact results, and no opsys needed on the controller
(such as embedded linux.)

Creation of simple yet VERY compact executables for a native operating
system, such as Linux or (heaven forbid) Windows.

The ability to create a new programming language.

My motivation here is primarily curiosity, but I am also motivated to
work around the very major issue with LabVIEW, and that is a compiled
application that is either 8-12Mb in size, or requires the addition of
a 7 (or so)Mb dll (the runtime engine).  There are of course other
reasons, as noted above, but as I said, I am mostly curious.  I
consider writing a compiler in LabVIEW to be a great challenge.  As
soon as I learn how to write one, I may in fact take on the challenge
myself.  I have even begun reading a tutorial someone created and made
available online for such purposes.

Thanks



Sat, 25 Dec 2004 23:50:07 GMT  
 Anyone ever write a compiler in LabVIEW


Quote:
> My motivation here is primarily curiosity, but I am also motivated to
> work around the very major issue with LabVIEW, and that is a compiled
> application that is either 8-12Mb in size, or requires the addition of
> a 7 (or so)Mb dll (the runtime engine).  There are of course other
> reasons, as noted above, but as I said, I am mostly curious.  I
> consider writing a compiler in LabVIEW to be a great challenge.  As
> soon as I learn how to write one, I may in fact take on the challenge
> myself.  I have even begun reading a tutorial someone created and made
> available online for such purposes.

Still not particularly clear on your original request.  Do you want labview
to compile your own language with your own syntax and grammar, or are you
writing a compiler for g-language programs?

The former, a compiler written in Labview, seems like a reasonable problem,
but this doesn't seem like what you are trying to do.  The latter, a g-
language compiler, seems formidable.  This is, in fact, what labview does
for a living!  It takes g-lang programs, optimally (in some sense, possibly
execution time, but clearly not size!) compiles them, and runs them, all
while hiding the {*filter*} build, as well as the executable, from the user.  

This clearly isn't insurmountable-- Labview's creators did it in a finite
amount of time and not much in the way of resources-- but the things that
would make life easy for you are very likely industrial secrets!!  You might
even be better off starting from scratch.  You'd almost be rewriting labview
anyway.

When you think about it, most big apps have some sort of cheap, shareware,
or open source "equivalent".  Even a powerhouse like Matlab has it's Octave.  
For some reason ( size of task or legal obstacle, most likely), nobody has
been able to open up Labview.  There are some interesting preprocessor
approaches that you might want to consider--Computerboards provides a
graphical VBasic preprocessor that you might find interesting.  Matlab has
Simulink, which is a Matlab preprocessor for a graphical "language" somewhat
similar to labview, and there is a matlab compiler available.

Another interesting starting point might be labviewRT, which seems to be
compiled to run on an embedded system.

Scott



Sun, 26 Dec 2004 06:48:34 GMT  
 Anyone ever write a compiler in LabVIEW
Obviously I'm not getting my message across, so I'll try again.

I want to write a compiler with LabVIEW.  No, I don't want to be able
to write code in LabVIEW and have it made into an executable.  I
basically want to write a programming language that this program can
change into executable code.

Nothing that exists today is what I am looking for, nothing I have
seen anyway.

For example.  LabVIEW Application Builder converts LabVIEW code into
either an executable file, or a DLL.

I want to build an application in LabVIEW in which I enter (through a
means I have not yet determined) instructions and the application
compiles this set of instructions into machine code which can execute
on my machine.

Typically, compilers are written in C or C++.  The tutorial I am
reading instructs the user to create the compiler in either gcc (the
GNU C++ Compiler) or Microsoft Visual C++ IDE (A compiler inside of an
Integrated Development Environment.)

Instead of writing this compiler in C/C++, I want to write it in
LabVIEW.  If I follow the tutorial, the compiler will take a C program
(a .c source file) and compile it into an executable for an intel
chipset (x86).

The problem I am having is that the tutorial instructs the writing of
the tutorial in C.  As I don't have a reference manual for all of the
libraries and commands called by the compiler and examples, I can't
know exactly how to mimic the C code in LabVIEW.

Sure, I could write it in C, create it as a DLL, and then use LabVIEW
to call the CIN or DLL, but that would defeat the purpose.

Just so that it is known, this is nothing more than a hobby project.
I am trying to determine just how capable LabVIEW is, and at the same
time, learn how to create a compiler.  As a side benefit, I will learn
a little bit about C/C++.  I was told that the best possible way to
learn C/C++ was to write a compiler.  It gives you a very intimate
understanding of the programming language.  I figure I can kill two
birds with one stone.  Another note, this project's results will be a
complete waste of time and effort.  There are already tons of
compilers out there.  I am hoping to learn a lot about compilers,
programming languages, and the capabilities of LabVIEW.



Sun, 26 Dec 2004 07:57:19 GMT  
 Anyone ever write a compiler in LabVIEW


Quote:
> Obviously I'm not getting my message across, so I'll try again.

> I want to write a compiler with LabVIEW.  No, I don't want to be able
> to write code in LabVIEW and have it made into an executable.  I
> basically want to write a programming language that this program can
> change into executable code.

> Nothing that exists today is what I am looking for, nothing I have
> seen anyway.

> For example.  LabVIEW Application Builder converts LabVIEW code into
> either an executable file, or a DLL.

> I want to build an application in LabVIEW in which I enter (through a
> means I have not yet determined) instructions and the application
> compiles this set of instructions into machine code which can execute
> on my machine.

> Typically, compilers are written in C or C++.  The tutorial I am
> reading instructs the user to create the compiler in either gcc (the
> GNU C++ Compiler) or Microsoft Visual C++ IDE (A compiler inside of an
> Integrated Development Environment.)

> Instead of writing this compiler in C/C++, I want to write it in
> LabVIEW.  If I follow the tutorial, the compiler will take a C program
> (a .c source file) and compile it into an executable for an intel
> chipset (x86).

> The problem I am having is that the tutorial instructs the writing of
> the tutorial in C.  As I don't have a reference manual for all of the
> libraries and commands called by the compiler and examples, I can't
> know exactly how to mimic the C code in LabVIEW.

> Sure, I could write it in C, create it as a DLL, and then use LabVIEW
> to call the CIN or DLL, but that would defeat the purpose.

> Just so that it is known, this is nothing more than a hobby project.
> I am trying to determine just how capable LabVIEW is, and at the same
> time, learn how to create a compiler.  As a side benefit, I will learn
> a little bit about C/C++.  I was told that the best possible way to
> learn C/C++ was to write a compiler.  It gives you a very intimate
> understanding of the programming language.  I figure I can kill two
> birds with one stone.  Another note, this project's results will be a
> complete waste of time and effort.  There are already tons of
> compilers out there.  I am hoping to learn a lot about compilers,
> programming languages, and the capabilities of LabVIEW.

Labview is a very capable language in itself.  To use it to compile code
written in another language would be a waste of time seeing that the whole
point of Labview is to reduce development time, not add another layer of
complexity.

If you want to learn C\C++ I recommend getting a book and working the
examples, I like Thinking in C++ by Bruce Eckel it is available for free on
electronic form or you can by the paper version.



Sun, 26 Dec 2004 11:58:51 GMT  
 Anyone ever write a compiler in LabVIEW

Quote:
> Obviously I'm not getting my message across, so I'll try again.

Here is my advice.

1.  Compilers are very language specific.  Determine what language you
will be parsing.  College compiler courses don't do compilers for whole
languages, they have a C, Pascal, or Java subset that they define as
their language.  The formula box I mentioned in my previous email,
pretty much a C subset.

2.  Get a book like the dragon book by Aho, Sethi, and Ullman.  Not sure
about the spelling, but this is/was the bible when I was in school.
also, you might look for free educational material on various university
web sites.

3.  Write the parser -- a major undertaking, especially in LV due there
not being an efficient and easy way of recursing.  I mentioned the
mathematics VIs having a parser.  Note that it has lots of limitations
on variable lengths and such, and if you ask the guy who wrote it he
would love to rewrite it.  This is pretty much always the case with
parsers.  They are just plain hard to write, hard to verify, etc.  This
is why you might want to consider looking at tools such as Lex and Yacc
or Bison.  These tools make the parser code very standardized and much
easier to generate and regenerate as you change the syntax of the
language.  The formula node's parser ... written using Bison.

4.  Determine if this will really be compiled or interpretted.
Interpretors are way easier, and they are usually portable.  If you do
the code gen, then get a good reference book for the processor you are
using, a good de{*filter*}, and a good disassembler.

5.  Have fun, and even if you never get very far, you will learn tons
from the books.

Greg McKaskle



Sun, 26 Dec 2004 22:35:44 GMT  
 Anyone ever write a compiler in LabVIEW
Labviewguru,

would a script be sufficient for your purpose? It is rather simple to
generate a VBScript or jscript with LabVIEW. On Win2K and higher,
typing the script name on the command line or system exec runs the
script like for batch files. The ActiveX component "Windows Script
Control" allows you to manipulate and run scripts in memory rather
than on file.

They are not executable but much nore simple to implement than a
compiler to generate machine instructions.



Sun, 26 Dec 2004 23:36:01 GMT  
 Anyone ever write a compiler in LabVIEW
Sorry Labviewguru,

Now that I have read the full thread, it is obviously not the answer
you required.



Sun, 26 Dec 2004 23:45:04 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. anyone done capture with 5112 then write same out to 5411 directly in Labview 6i

2. Has anyone written some LabVIEW to convert Lat/Long Co-ordinates into British Grid

3. Anyone ever purchased Getty images?

4. Has anyone ever...

5. Has anyone ever used DT-LV link software????

6. Has anyone ever done a history of Stack Machines

7. Has anyone ever experienced this...

8. Mad Apple Forth, anyone ever use it?

9. Weird situation - anyone ever seen it?!

10. Anyone ever heard of Pro1?

11. Anyone ever heard of Sapien(?spelling) language?

12. Has anyone ever used DT-LV link software????

 

 
Powered by phpBB® Forum Software