LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-02-2017, 11:27 PM   #1
des_a
Member
 
Registered: Sep 2006
Posts: 855
Blog Entries: 33

Rep: Reputation: 20
PNFHA: Is it High Level, or Mid Level?


I've been considering something a lot. Is my language that I've been working on, PNFHA, really a high-level language, or is it more like a mid-level language upon which a true high-level language should be built? I can give examples, if needed. But what I find, is that the best practice so far when coding in it, is to think a bit about both what is happening in your code, and what's going on a the level below it (PNFASM).
 
Old 04-03-2017, 01:55 PM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,217
Blog Entries: 13

Rep: Reputation: 4275Reputation: 4275Reputation: 4275Reputation: 4275Reputation: 4275Reputation: 4275Reputation: 4275Reputation: 4275Reputation: 4275Reputation: 4275Reputation: 4275
Where's the language reference for this?
 
1 members found this post helpful.
Old 04-03-2017, 02:16 PM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 9,078
Blog Entries: 4

Rep: Reputation: 3185Reputation: 3185Reputation: 3185Reputation: 3185Reputation: 3185Reputation: 3185Reputation: 3185Reputation: 3185Reputation: 3185Reputation: 3185Reputation: 3185
Quote:
Originally Posted by des_a View Post
I find [...] that the best practice [...] when coding in it, is to think a bit about both what is happening in your code, and what's going on a the level below it (PNFASM).
But, isn't that always the case?

In my vernacular (which ordinarily doesn't spend too much time thinking about such things ...), a "low-level" language would be "assembler," and a "mid-level" language might be something that is really intended only to be generated by another compiler. (Java's intermediate language, PostScript, and less-known tools such as NME and Lua all come to my mind.) A "high-level" language would be intended for use directly by humans.

And there certainly would be cross-overs. "C" was a language that was expressly conceived for the implementation of Unix® at Bell Labs. It supported an asm {...} construct that allows assembler code to be directly inserted, and most but not all subsequent implementations carried-on that tradition. Unix was therefore one of the first operating systems – if not the first – that was implemented in a high-level language.

All of these terms are, frankly, "too vague to be very useful," except in a very colloquial way.

Your observation of the need to be aware of what is going on "in your code and in 'the level below it'" is very prescient. Always keep this firmly in mind. "The level below it" of course may not or may not directly be "the hardware."
 
1 members found this post helpful.
Old 04-06-2017, 05:14 PM   #4
des_a
Member
 
Registered: Sep 2006
Posts: 855

Original Poster
Blog Entries: 33

Rep: Reputation: 20
Unfortunately, I can't remember the example I was thinking of anymore. I'll have to see if I can find it again as I go along.
 
Old 04-06-2017, 05:14 PM   #5
des_a
Member
 
Registered: Sep 2006
Posts: 855

Original Poster
Blog Entries: 33

Rep: Reputation: 20
Maybe I'd fixed it?
 
Old 04-06-2017, 05:18 PM   #6
des_a
Member
 
Registered: Sep 2006
Posts: 855

Original Poster
Blog Entries: 33

Rep: Reputation: 20
Here is some code that I think begins to show you what I mean, but wasn't the example I was thinking of:

Correct:
Code:
var a = 5;


==; ? { print "a = "; println a; } : ;;

println "Done!";


end 0;
What you'd think would work if you knew C++:
Code:
var a = 5;


if (a == 5)
{
 print "a = "; 
 println a; 
}

println "Done!";


end 0;
For some reason, the second example, actually crashes, which is probably an error on my part, but it does not work.
 
Old 04-06-2017, 05:19 PM   #7
des_a
Member
 
Registered: Sep 2006
Posts: 855

Original Poster
Blog Entries: 33

Rep: Reputation: 20
Output from the above correct code:

Code:
a = 5
Done!
 
Old 04-06-2017, 05:21 PM   #8
des_a
Member
 
Registered: Sep 2006
Posts: 855

Original Poster
Blog Entries: 33

Rep: Reputation: 20
Syntax of this language:

Code:
Portable Numbers Format High Level Language A (PNFHA)
=====================================================

SYNTAX
======

input:	(newline)
	| statement (newline)

statement:	stmt
		| statement , stmt

stmt:	control_statement
	| ;
	| expression_statement
	| declaration_statement
	| command_statement
	| label_statement
	| statement_block
	| pp_directive
	| pp_statement

expression_statement:	expression ;

declaration_statement:	declaration ;

command_statement:	command ;

label_statement:	ID :
			| sub ID :
			| event ID :

control_statement:	if_statement
			| switch_statement
			| loop_statement

if_statement:		if ( expression ) stmt
			[else stmt]

switch_statement:	switch ( expression ) { case_statements opt_default_statement }

case_statements:	case_statements
			| case_statements case_statement

case_statement:		case expression : stmt

opt_default_statement:	[default : stmt]

loop_statement:		while_loop

while_loop:		while ( stmt ) stmt

statement_block:	{ statements }

statements:		statement
			| statement statements

expression:		void_expression
			| boolean_expression
			| number_expression
			| character_expression
			| string expression
			| id_expression
			| relational_expression
			| mixed_expression

void_expression:	0V
			| ( void_expression )

boolean_expression:	BOOLEANV
			| ! boolean_expression
			| boolean_expression && boolean_expression
			| boolean_expression || boolean_expression
			| ( boolean_expression )

number_expression:	NUMBERV
			| number_expression + number_expression
			| number_expression - number_expression
			| number_expression * number_expression
			| number_expression / number_expression
			| number_expression % number_expression
			| - number_expression
			| number_expression ^ number_expression
			| number_expression !^ number_expression
			| ++ number_expression
			| number_expression ++
			| -- number_expression
			| number_expression --
			| number_expression & number_expression
			| number_expression | number_expression
			| number_expression ^| number_expression
			| ~ number_expression
			| number_expression << number_expression
			| number_expression >> number_expression
			| ( number_expression )

character_expression:	CHARACTERV
			| character_expression + character_expression
			| character_expression - character_expression
			| character_expression * character_expression
			| character_expression / character_expression
			| character_expression % character_expression
			| character_expression ^ character_expression
			| character_expression !^ character_expression
			| ++ character_expression
			| character_expression ++
			| -- character_expression
			| character_expression --
			| ( character_expression )

string_expression:	STRINGV
			| string_expression + string_expression
			| $ string_expression
			| ( string_expression )

id_expression:		ID
			| & id_expression
			| ! id_expression
			| id_expression && id_expression
			| id_expression || id_expression
			| id_expression + id_expression
			| id_expression - id_expression
			| id_expression * id_expression
			| id_expression / id_expression
			| id_expression % id_expression
			| - id_expression
			| id_expression ^ id_expression
			| id_expression !^ id_expression
			| ++ id_expression
			| id_expression ++
			| -- id_expression
			| id_expression --
			| ( id_expression )

relational_expression:	number_expression == number_expression
			| number_expression != number_expression
			| number_expression > number_expression
			| number_expression < number_expression
			| number_expression >= number_expression
			| number_expression <= number_expression

mixed_expression:	( mixed_expression )
			| ID && boolean_expression
			| boolean_expression && ID
			| ID || boolean_expression
			| boolean_expression || ID
			| ID + number_expression
			| ID - number_expression
			| ID * number_expression
			| ID / number_expression
			| ID ^ number_expression
			| ID !^ number_expression
			| number_expression + ID
			| number_expression - ID
			| number_expression * ID
			| number_expression / ID
			| number_expression ^ ID
			| number_expression !^ ID
			| ID + character_expression
			| ID - character_expression
			| ID * character_expression
			| ID / character_expression
			| ID ^ character_expression
			| ID !^ character_expression
			| character_expression + ID
			| character_expression - ID
			| character_expression * ID
			| character_expression / ID
			| character_expression ^ ID
			| character_expression !^ ID
			| ID + string_expression
			| string_expression + ID
			| number_expression == ID
			| number_expression != ID
			| number_expression < ID
			| number_expression > ID
			| number_expression <= ID
			| number_expression >= ID
			| ID == number_expression
			| ID != number_expression
			| ID < number_expression
			| ID > number_expression
			| ID <= number_expression
			| ID >= number_expression
			| ID & number_expression
			| ID | number_expression
			| ID ^| number_expression
			| number_expression & ID
			| number_expression | ID
			| number_expression ^| ID
			| number_expression << ID
			| number_expression >> ID
			| ID << number_expression
			| ID >> number_expression

declaration:	variable_declaration
		| label_declaration
		| enum_declaration
		| range_declaration

variable_declaration:	var ID
			| var ID = expression
			| fvar ID
			| enumv_declaration
			| rangev_declaration
			| array_declaration

enumv_declaration:	enumv STRINGV STRINGV = STRINGV

rangev_declaration:	rangev RTYPE2 STRINGV STRINGV = STRINGV

array_declaration:	array STRINGV [ number_expression ]

label_declaration:	sub ID
			| event ID

enum_declaration:	enum ID = { enum_strings }

enum_strings:		STRINGV
			| enum_strings , enum_strings

range_declaration:	range RTYPE2 STRINGV = STRINGV .. STRINGV

command:	print_command
		| read_command
		| end_command
		| asm_command
		| load_command
		| goto_command
		| operator_command
		| st_command
		| stack_command
		| typeof_command
		| rm_command
		| crash_command
		| version_command
		| halt_command
		| modt_command
		| subroutine_command
		| register_command
		| store_command
		| break_command
		| address_command
		| add2v_command
		| continue_command
		| check_command
		| comment_command
		| file_command
		| meml_command

print_command:	print
		| print expression
		| print ver
		| println
		| println expression
		| println ver
		| eprint
		| eprint expression
		| eprintln
		| eprintln expression
		| fprint
		| fprint expression
		| fprintln
		| fprintln expression

read_command:	read TYPE ID
		| fread TYPE ID

end_command:	end number_expression

asm_command:	asm STRINGV STRINGV string_expression

load_command:	load RTYPE LTYPE number_expression
		| load RTYPE LTYPE TYPE
		| load LTYPE
		| load LTYPE boolean_expression
		| load LTYPE string_expression
		| load RTYPE LTYPE ID
		| load STYPE number_expression
		| load venum STRINGV
		| load range RTYPE2 STRINGV
		| load range RTYPE2 STRINGV [ number_expression ]
		| load array STRINGV [ number_expression ]

goto_command:	goto GTYPE number_expression
		| goto GTYPE ID

operator_command:	+
			| + number_expression
			| + character_expression
			| + string_expression
			| -
			| \- number_expression
			| *
			| * number_expression
			| /
			| / number_expression
			| %
			| % number_expression
			| ^
			| ^ number_expression
			| !^
			| !^ number_expression
			| ++
			| --
			| &&
			| ||
			| !
			| ==
			| !=
			| <
			| >
			| <=
			| >=
			| == boolean_expression
			| != boolean_expression
			| == number_expression
			| != number_expression
			| < number_expression
			| > number_expression
			| <= number_expression
			| >= number_expression
			| == character_expression
			| != character_expression
			| < character_expression
			| > character_expression
			| <= character_expression
			| >= character_expression
			| &
			| "|"
			| ^|
			| ~
			| <<
			| >>

st_command:	st

stack_command:	push
		| pop

typeof_command:	typeof RTYPE

rm_command:	atoc
		| switch

crash_command:	crash string_expression

version_command:	version VTYPE

halt_command:	halt

modt_command:	modt RTYPE

subroutine_command:	return
			| gosub number_expression
			| gosub STYPE ID

register_command:	unregister STYPE
			| register STYPE ID
			| reregister STYPE ID ID

store_command:	store RTYPE LTYPE number_expression
		| store RTYPE LTYPE
		| store storea
		| store venum STRINGV
		| store range RTYPE2 STRINGV
		| store array STRINGV [ number_expression ]

break_command:	break
		| break ID

address_command:	addressof ATYPE ID

add2v_command:	add2v

continue_command:	continue

check_command:	check CTYPE TYPE number_expression
		| check CTYPE TYPE boolean_expression
		| check CTYPE TYPE character_expression
		| check CTYPE TYPE string_expression
		| check CTYPE number_expression

comment_command:	comment CMTYPE string_expression

file_command:	fmode BFMODEC FMODEC
		| fopen BFMODEC string_expression
		| fclose FBMODEC
		| feof

meml_command:	meml

pp_directive:	%BIN%
		| %PBIN%
		| %LIB%

pp_statement:	%include STRINGV
		| %include <STRINGV>
		| %import STRINGV
		| %import <STRINGV>
		| %define STRINGV STRINGV
		| %macro STRINGV STRINGV
		| %endm
		| %undef STRINGV
		| %ifdef STRINGV
		| %ifndef STRINGV
		| %else
		| %endif
		| _DATE()
		| _TIME()
		| _LINE()
		| _FILE()
		| _CDATE()
		| _CTIME()
		| '! {CHARACTERV}*
		| %%include STRINGV
		| %%include <STRINGV>
		| %%import STRINGV
		| %%import <STRINGV>
		| %%define STRINGV STRINGV
		| %%macro STRINGV STRINGV
		| %%endm
		| %%undef STRINGV
		| %%ifdef STRINGV
		| %%ifndef STRINGV
		| %%else
		| %%endif
		| %_DATE()
		| %_TIME()
		| %_LINE()
		| %_FILE()
		| %_CDATE()
		| %_CTIME()
		| %%'! {CHARACTERV}*


ID = [[:alnum:]]*

BOOLEANV = "true"|"false"

NUMBERV = {DIGIT}+|{DIGIT}+"."{DIGIT}*

DIGIT = [0-9]

CHARACTERV = '.'

STRINGV = \"{TCHARACTER}*\"

TCHARACTER = [^\"\n]

TYPE = "void"|"boolean"|"number"|"character"|"string"

RTYPE = "%accumulator"|"%calc"

LTYPE = "memory"|"variable"|"tend"|"type_of"|"iname"|"icount"|"args"|"aload"|"argn"

STYPE = "sub"|"heve"|"sheve"|"eve"|"exe"|"int"

GTYPE = "normal"|"condition"|"zero"|"positive"|"negative"

VTYPE = "pnf"|"norm"

ATYPE = "avariable"|"alabel"|"aevent"

COMMENT = #{TCHARACTER}*

CTYPE = "ver"|"current_ver"|"instruction"|"type"

CMTYPE = "l1"|"l2"

BFMODEC = "input"|"output"

FMODEC = "in"|"out"|"binary"|"ate"|"app"|"trunc"

RTYPE2 = "rtype1"|"rtype2"
 
Old 04-06-2017, 05:22 PM   #9
des_a
Member
 
Registered: Sep 2006
Posts: 855

Original Poster
Blog Entries: 33

Rep: Reputation: 20
That is straight from my documentation.
 
Old 04-06-2017, 05:41 PM   #10
des_a
Member
 
Registered: Sep 2006
Posts: 855

Original Poster
Blog Entries: 33

Rep: Reputation: 20
The original problem I was thinking of stems from the fact that a variable is just a construct in the compiler and can't always update the variable which results in PNFASM. Maybe however, it really is a high-level language. Certainly I'll build on top of it more later though...
 
Old 04-06-2017, 06:06 PM   #11
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_12{.0|.1}
Posts: 5,553
Blog Entries: 11

Rep: Reputation: 3508Reputation: 3508Reputation: 3508Reputation: 3508Reputation: 3508Reputation: 3508Reputation: 3508Reputation: 3508Reputation: 3508Reputation: 3508Reputation: 3508
The syntax listing does not really help us understand what the language actually does. Imagine trying to understand how to use C beginning with only the BNF syntax listing!

You have posted many times about your PNF language, and I have tried to understand much of it, without success. Because you are the author of it and the sole source of information about it, it is really up to you to help us understand its purpose, applications, advantages over other languages, etc.

What would be helpful would be a short introduction to the language, to which you could refer when asking questions about it. If that would be very lengthy, I would suggest that you use your blog space here on LQ to build up a useful set of documentation which you, and we could refer to as needed.

For example, what does "Portable Number Format" actually mean with regard to your language?

What problem does it solve?

How does it compare to other languages?

You have stated that it is better than Java in some sense. How so? What advantage does it have in such a comparison?

How exactly are PNFASM, PNFHA and PNFPP related to each other, and to the problem area of interest?

A simple language description and a few very simple, specific and well written examples would go a very long way toward helping others understand its purpose and use.

Without such a reference point it is very difficult for others here to offer advice or help, or even to understand the questions and examples.

So before posting more lengthy threads about PNF{ASM,HA,PP,etc.}, I would ask that you please devote some effort to providing useful answers to the above questions, some easily accessible language reference docs, and some simple, useful examples of how it may be used to solve some specific, simple test cases. That will allow others to provide answers to your own questions, and help to keep the information in these threads more useful to you and to others.

Last edited by astrogeek; 04-06-2017 at 06:25 PM.
 
Old 04-06-2017, 09:18 PM   #12
des_a
Member
 
Registered: Sep 2006
Posts: 855

Original Poster
Blog Entries: 33

Rep: Reputation: 20
I'll try to answer some of your questions here:

Quote:
For example, what does "Portable Number Format" actually mean with regard to your language?
"Portable Numbers Format", is the term I have decided to use, because it seemed like it was not already in use. Let's break it down. "Portable" means that it essentially runs the way Java does most of the time or as needed. More like GCJ actually, because it has a way already to make an executable from it. "Numbers Format", refers to the binary part of the language, which is "Portable Numbers Format", or "PNF" for short. The language consists of two main parts:

1. A signature: "!@.PNF"

* Like a Windows program, that starts with "MZ", it can help tell it apart from another type of file.

2. The numbers: It uses C++ doubles as defined by my compiler. Whitespace doesn't matter, but it makes sense to logically arrange them in a good order.

* This was why I used C++ to create this part, and NOT a compiler compiler. A compiler compiler would have complicated the algorithm for loading the file. C++ makes it easy. First load the signature, which is a String. Then load the numbers, which are doubles. This seems to be part of what makes it comparable in speed to Java bytecode. If it's slower at all, it's not noticeable.

* The "numbers" consist of an instruction, a type, and an opcode. The opcode may be longer than one number, if it's a string. Usually, but not always, the type and the opcode type match each other. There are 5 types:

* VOID
* BOOLEAN
* NUMBER
* CHARACTER
* STRING

These are built in types basically. Numbers are all the same precision.

Quote:
What problem does it solve?
This language makes doing lower level work easier for the average programmer. You would still work at the highest level possible for your particular problem. However, if you need to "tweak" your program, you can do so at the lower levels in an easier way. Because it is human readable numbers, at the lowest level, the computer is sort of meeting you in the middle of the lower language part. You can change it as it's just a text file, and the computer can read it without too much slowdown on most OSs. It will attempt to solve many of the same problems that have already been solved. It will be a general purpose language. Not that I would re-write other programs just for this language's features, but newer programs could be written in it.

It will eventually make programming and creating operating systems easier. I will write a real OS, that is a PNF interpreter, later, when I have the skills. Then you can make an OS by using these languages. I'll provide a standard OS, which I want people to use. But I really want to see creativeness out there for programmers as well, so that the average programmer can create an OS with little effort. Bootloaders and everything. I'll make ways to allow it to be native, if the programmer desires it to be, possibly for a higher fee.

Quote:
How does it compare to other languages?
Other languages are not as easy to use at the lowest levels. And I hope eventually, that they will not be as powerful either.

Quote:
You have stated that it is better than Java in some sense. How so? What advantage does it have in such a comparison?
It's better basically because it's easiest to use at the lower level. And I'm going to be developing things so that I will have many languages written on top of the lower level, possibly using each other. I will encourage others to be creative once I get it out there, and produce their own languages on top of the lower levels. There would be not much wrong with a version of Java written on top of my language instead of it's own bytecode. However, my languages, will eventually be easier to use at the highest level as well. That's because plans are in the works for a new language called "English Like", which will be a specialized type of English, but will use valid English sentances and paragraphs. As far as I know, nobody has standardized programming in this way before. That will be the highest level of this.

Later when voice recognition becomes more standard, a version could be written on, let's say Alexa, that would allow you to use words using your voice to type an "English Like" program, which you could then compile and run on your PNF interpreter. And like always, you can compile that to an actual executable.

Quote:
How exactly are PNFASM, PNFHA and PNFPP related to each other, and to the problem area of interest?
PNF is the lowest level. It is a binary format. PNFASM is an assembler that works on top of PNF, much like we have x86 assembly language compiled to binaries. PNFHA, as I'm discussing here, was something I had in mind to be a high level language that translates to PNFASM. PNFPP is the standard preprocessor for the entire language. It is used many places and is sometimes automatically used.
 
Old 04-06-2017, 09:21 PM   #13
des_a
Member
 
Registered: Sep 2006
Posts: 855

Original Poster
Blog Entries: 33

Rep: Reputation: 20
This page is just meant to be a discussion of whether PNFHA is high-level or not. Also a sort of informational thread about the language, but mostly the first. It is not meant to solve an actual problem.
 
Old 04-06-2017, 09:23 PM   #14
des_a
Member
 
Registered: Sep 2006
Posts: 855

Original Poster
Blog Entries: 33

Rep: Reputation: 20
I'd expect that the first version will flop because even though it's really powerful, it's not powerful enough for my users yet.
 
Old 04-06-2017, 09:27 PM   #15
des_a
Member
 
Registered: Sep 2006
Posts: 855

Original Poster
Blog Entries: 33

Rep: Reputation: 20
The first non-textbook and non-test program, I will write in this new language (suite of languages), will be itself re-written in itself. But it can't do that yet. That is how I know the higher level parts are working. When I can do that, the higher level parts are working. It's probably possible, if I wanted to use the lower levels, but even though they're easier to use than other lower level languages, they are still lower level languages, and that act would be crazy. So I need the higher levels to work first before I work on the code for itself.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Looking for full-time mid & senior level Systems Administrator(s) in Santa Monica, CA BrianK LQ Job Marketplace [Archive] 0 12-08-2008 08:33 PM
emacs in run level 3 then switch to X (level 7) then back to level 3 dsoliver Slackware 3 09-01-2006 04:31 AM
Junior to Mid-Level Systems Administrator Position kordump LQ Job Marketplace [Archive] 0 08-10-2006 09:45 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:46 AM.

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