LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-18-2013, 11:15 AM   #151
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 352

Original Poster
Rep: Reputation: Disabled

You might consider taking the posts on this topic and writing a book. It would be very useful to people 1)Building a stack machine, 2) building a compiler especially with bison. I would have found it useful for my work.
 
Old 12-18-2013, 03:10 PM   #152
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
It is one of the things I've thought of - Especially by taking a relatively simple language and providing the steps to go from creating a grammar, to parsing to code generation... then to interpretation - and showing the interaction between the code generation and the interpretation (almost need the interpreter before the code generator as in our case).

May still try that as a E-book or a blog series (what I have now would need a lot of cleanup, improvement in the data structures, symbol tables, and maybe even adding data structures). It would be introductory only, as the topic is actually quite large and there are several 300+ page books on the subjects (Aho and Ullman has done an entire series). There are also several that could be done with the LLVM compiler construction base, which aims at producing retargetable compilers (haven't used it yet) which came out just a couple of years ago. One of the known limitations of LR(1) parser generators (like Bison is basically) is that it is harder to get error handling right. It is easy to say "parser error at line #" but to say WHY it is an error, to make correction suggestions, and recover to continue looking for more errors is much harder. Bison has extensions to make it easier, but it also starts taking it out of the LR(1) grammar to do so. Complex grammars (even GCC) have been migrating from an LR(1) parser to an LL(1) parser (this uses recursive decent instead of parse tables) because it makes the context of an error MUCH easier to handle. Its just that LL(1) parser generators have not been generally available (they exist, but are rather difficult to use, but things are improving - I believe that is how LLVM works, but I'm not sure). One thing I will need is to get a newer book ("Flex and Bison" from O'Rilly). The new stuff is hard to follow from the reference manual (which is on line by the way).

I remember one of the early Pascal books - I learned a lot about both the Pascal compiler/interpreter (I was the maintainer while a senior) was at the end of the book... It included a "tiny Pascal" with the P-code interpreter. Another was the Concurrent Pascal book that added extensions (~1975 by Per Brinch Hanson) to turn Pascal into a system implementation language - it too included a lot of the compiler, though mostly it had what Microsoft now calls "managed software" for creating a "near-realtime" (as long as you aren't trying to do hard realtime) operating systems and utilities (one of which was the compiler...).

The interpreter itself was for a PDP-11/45, and turned a 16 bit CPU (with 16 bit addressing), with 18 bit hardware address into a threaded code machine with 256k addressability. As I recall, the interpreter itself was fairly small - 8-12K or so.

Last edited by jpollard; 12-18-2013 at 03:33 PM.
 
1 members found this post helpful.
Old 12-19-2013, 01:07 AM   #153
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 352

Original Poster
Rep: Reputation: Disabled
I think I am going to take the week off between Christmas and New Years and do something else. Probably some electronics and have to help out an elderly lady with house repairs. I will get a kit for a radio that operates around 49 MHz as well as I have an oscillator to try to test for repeat-ability and temperature stability.
 
Old 12-19-2013, 04:08 AM   #154
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Have fun.

I'm going to think about the data structures, and (if my wife lets me get to the computer) think about adding experiments with local variables. Might add a bit to the stack machine (a block transfer would be useful).
 
Old 12-24-2013, 10:38 PM   #155
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 352

Original Poster
Rep: Reputation: Disabled
Merry Christmas Jesse. One thing about errors in code is that you really get to know what you wrote. The code is becoming like an old friend. The more I look at it the better I know it.
 
Old 12-25-2013, 07:28 AM   #156
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Same to you.

Just wait until you are away from it for a couple of months... and then try to fix a bug....

It is what taught me to try and document things better...
 
Old 12-26-2013, 01:38 AM   #157
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 352

Original Poster
Rep: Reputation: Disabled
I think I am going to go all the way and include a real time clock with coin battery backup and a mass storage USB port running FAT32 file system.
 
Old 12-26-2013, 07:07 AM   #158
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Depending on how it is used, that will call for a kernel running too - device drivers, buffers, applications, and filesystem. Possibly two - one for the FAT32, and one for flash and updates, though that second one might be optional.
 
Old 12-26-2013, 08:47 AM   #159
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 352

Original Poster
Rep: Reputation: Disabled
The real time clock maintains itself and is accessed over I2C bus. There is only one program running - the interpreter. File I/O through the FAT system is also through the interpreter.
 
Old 12-26-2013, 09:33 AM   #160
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
The main issue is that unless you use programmed I/O on the USB, you now have interrupts (or a huge amount of spin lock delay loops waiting for the data). It also means that unless you have interrupts, the interpreter will stop until the file system activity and I/O are completed - per action, thus introducing a rather long delay for any responses.

It also means that the filesystem support, and USB support have to implemented locally - along with the debugging.

It isn't impossible... just time consuming. It usually means the interpreter becomes the operating system.
 
Old 12-26-2013, 09:56 AM   #161
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 352

Original Poster
Rep: Reputation: Disabled
I have since changed my mind and will use a SD Card instead of USB port. The only USB port will be a serial I/O port to the PC and is handled by an FTDI chip with RX, TX, CTS and RTS. Any interrupts will be built into the interpreter with no user interaction except through PRINT and INPUT statements through the interpreter.
 
Old 12-28-2013, 12:21 AM   #162
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 352

Original Poster
Rep: Reputation: Disabled
Microchip has Linux Ubuntu for MPLABX (their IDE) and Ubuntu for XC32 (their C compiler). The C compiler is C++/C.
 
Old 12-28-2013, 05:41 AM   #163
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Nice. At least everything should be available for use.
 
Old 12-29-2013, 02:57 PM   #164
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
I've made some data structure changes - it simplified the grammar action routines considerably, but did make the code walking a bit trickier (meaning: I haven't debugged it yet .
 
1 members found this post helpful.
Old 12-31-2013, 11:43 AM   #165
schmitta
Member
 
Registered: May 2011
Location: Blacksburg VA
Distribution: UBUNTU, LXLE
Posts: 352

Original Poster
Rep: Reputation: Disabled
Considering ARM CORTEX M3(!?) You might want to consider ARMv7 for your stack machine as it is a 32 bit GPR RISC system. For information see: http://www.youtube.com/watch?v=7LqPJGnBPMM

Last edited by schmitta; 12-31-2013 at 12:36 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expressions nova49 Linux - Newbie 4 07-13-2011 07:05 AM
Regular Expressions Wim Sturkenboom Programming 10 11-19-2009 01:21 AM
regular expressions. stomach Linux - Software 1 02-10-2006 06:41 AM
Regular Expressions overbored Linux - Software 3 06-24-2004 02:34 PM
help with REGULAR EXPRESSIONS ner Linux - General 23 10-31-2003 11:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration