Making your own programming language...

Programming, for all ages and all languages.
CrYpTiC

Making your own programming language...

Post by CrYpTiC »

I've always been interested in making my own programming language, but... where would I start. If you wanted to make your own custom programming language, what would you use to make it? Another language? That's where I've always come to a slump...Any answers will help very much.
AGI1122

Re:Making your own programming language...

Post by AGI1122 »

This is sort of related to what I need help with. I have been writing a flatfile driver, that uses mysql queries to do stuff.

Now, what I need to figure out is how to "interpret" this part of the query as if it where a language:

WHERE ((cat_id=board_cat && board_id='1') || (board_name='Test'))

As you can see it is sort of like an if statment.

If ((cat_id=board_cat && board_id='1') || (board_name='Test')) {
// Select this row because it is in the where clause.
}

Not exactly sure how to parse something like this though. Oh and I am writing this in PHP incase it helps.
CrYpTiC

Re:Making your own programming language...

Post by CrYpTiC »

Tim, that's really confusing lol. I got turbo pascal like it said, but whenever I put in the code he said to, it got errors. You think he wrote the coding wrong? The coding's on the intro part if you want to look at it.
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:Making your own programming language...

Post by df »

there is nothing wrong with crenshaws code. its just old.

i got it all working in C a few years back when I looked over the crenshaw notes...
-- Stu --
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:Making your own programming language...

Post by df »

Chris Cromer wrote: This is sort of related to what I need help with. I have been writing a flatfile driver, that uses mysql queries to do stuff.

Now, what I need to figure out is how to "interpret" this part of the query as if it where a language:

WHERE ((cat_id=board_cat && board_id='1') || (board_name='Test'))

As you can see it is sort of like an if statment.

If ((cat_id=board_cat && board_id='1') || (board_name='Test')) {
// Select this row because it is in the where clause.
}

Not exactly sure how to parse something like this though. Oh and I am writing this in PHP incase it helps.
write it in php and have php execute the contents of a string variable??

i dont really get what your trying to do.. sounds like your trying to workaround for a lack of triggers + stored procedures in mysql...
-- Stu --
Eero Ränik

Re:Making your own programming language...

Post by Eero Ränik »

CrYpTiC wrote: Tim, that's really confusing lol. I got turbo pascal like it said, but whenever I put in the code he said to, it got errors. You think he wrote the coding wrong? The coding's on the intro part if you want to look at it.
Yeah, the code's just written with Turbo Pascal 4... Try Free Pascal, the code works perfectly with it.
AGI1122

Re:Making your own programming language...

Post by AGI1122 »

df wrote:
Chris Cromer wrote: This is sort of related to what I need help with. I have been writing a flatfile driver, that uses mysql queries to do stuff.

Now, what I need to figure out is how to "interpret" this part of the query as if it where a language:

WHERE ((cat_id=board_cat && board_id='1') || (board_name='Test'))

As you can see it is sort of like an if statment.

If ((cat_id=board_cat && board_id='1') || (board_name='Test')) {
// Select this row because it is in the where clause.
}

Not exactly sure how to parse something like this though. Oh and I am writing this in PHP incase it helps.
write it in php and have php execute the contents of a string variable??

i dont really get what your trying to do.. sounds like your trying to workaround for a lack of triggers + stored procedures in mysql...

I can't execute the contents of it, because it uses a different system. For instance var=var2 while in php it would be var==var2 so the differences in language would cause it to not be possible.

Plus I have to worry about fields from other tables as well as data.

I am building my own database system in php. It's a flatfile system that uses mysql queries to write/read flat files on the server.
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:Making your own programming language...

Post by df »

so your writing a flatfile system and you need a SQL parser right??

good luck there.. SQL is a complex language.
the first database i ever remeber using was a flatfile system..

PC-File, the first shareware program ever.. circa 1981 or somegthing... i dunno. early 80's.

i started writeing my own DB system i still have some of it here somewhere. 64bit journaled goodness in C.
-- Stu --
AGI1122

Re:Making your own programming language...

Post by AGI1122 »

Yeah basically, an SQL parser is what I need to parse the WHERE clause of the queries.

I think my biggest challenge will be queries like this one:

Code: Select all

SELECT c.*, b.*, t.*, m.real_name, m.display_name, m.groups, l.real_name AS last_real_name, l.display_name AS last_display_name, l.groups AS last_groups, r.topic, r.log_time, r2.board, r2.mark_read FROM cbb_categories AS c, cbb_boards AS b, cbb_topics AS t, cbb_members AS m, cbb_members AS l LEFT JOIN cbb_mark_read AS r ON (r.userid='2' && r.topic=t.topic_id && r.type='1') LEFT JOIN cbb_mark_read AS r2 ON (r2.userid='2' && r2.board='9' && r2.type='0') WHERE (c.cat_id=b.board_cat && b.board_id='9' && t.topic_board=b.board_id && m.member_id=t.first_member_id && l.member_id=t.last_member_id) ORDER BY t.sticky DESC, t.post_time DESC LIMIT 0,15
This query has JOINS, WHERE, LIMIT, and ORDER BY as well as selects data from multiple tables and compares them... so this is going to be a very daunting task to do.
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:Making your own programming language...

Post by df »

have you looked at other flatfile systems? dbase? etc
-- Stu --
AGI1122

Re:Making your own programming language...

Post by AGI1122 »

No I haven't... link please?

EDIT: Found dbase... not what I need though. Any other flat file systems? :-\
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:Making your own programming language...

Post by df »

DBM is or was a flatfile type system.
i dont know of any flatfile system that is relational, most are non relational single table type beasts.

any reason you cant use a standard DB for whatever your trying to do??
-- Stu --
AGI1122

Re:Making your own programming language...

Post by AGI1122 »

Well I was making this for distribution with CBB, that way people could use flatfile if they don't have a real database(such as mysql).

I won't be using it myself, but wanted the option to be available for people.
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:Making your own programming language...

Post by df »

i think, if they are going to have a minimum php of 4.3.2 or something you can expect them to have mysql at least?
-- Stu --
Post Reply