Author Topic: [Resolved] Keywords List?  (Read 1834 times)

0 Members and 1 Guest are viewing this topic.

Mike Lobanovsky

  • Guest
[Resolved] Keywords List?
« on: March 21, 2018, 04:34:32 AM »
Hi Charles,

I find a utility function supported in a number of BASIC implementations and arbitrarily named here as ListKeywords() very helpful in one's development work.

The ListKeywords() function would dump to disk the entire sorted list of the dialect's keywords supported by the instance of compiler/interpreter currently running on the dev's desktop. It would list not only the key vocabulary but also all possible aliases the given parser/lexer can understand, e.g. use, uses, using, etc.

The list would also include the dialect's shorthand notation, e.g. *, @, &, etc.

Do you think such a function could also be added to the Oxygen core vocab?
« Last Edit: March 21, 2018, 11:10:52 AM by Mike Lobanovsky »

Charles Pegge

  • Guest
Re: Keywords List?
« Reply #1 on: March 21, 2018, 06:46:15 AM »
Hi Mike,

That would be easy for primary keywords which are held in the hash store, but most secondary keywords and operators are hard-coded.

Oxide has a facility for listing primary keywords, as seen by the compiler from any position in a program.
You can also embed

 #list "t.txt" key

into your program to get a listing in t.txt of all symbols containing 'key'. and their origin

Mike Lobanovsky

  • Guest
Re: Keywords List?
« Reply #2 on: March 21, 2018, 07:35:33 AM »
No Charles,

That's not what I mean. I am not concerned with the current cache(s) of the editor that loads this or that .o2bas script and its includes and is/are dependent on the 3rd party editor's own facilities to collect the sctipt metadata.

I'm rather talking about a utility function that would be exported from Oxygen.dll (or any other standard binary in a full O2 installation where the vocab happens to be hardcoded) that would list the actual keyword set this particular installation supports, including its core asm as well as C bits and pieces.

Regard this function as part of the editor's facilities to collect actual script/project metadata. Such facilities would always be generally dependent on the editor's own implementation/version. OTOH LoadKeywords() will always be guaranteed to be bound to nothing else but the installation alone.

Ideally, LoadKeywords() should support both dumping to a disk file and loading the list in memory as a space delimited string at the user's option based on whether its string literal/variable argument is empty or not.

The function could be an indispensable aid in the development of code editors and debuggers for various front ends built on top of O2 core engine.

Charles Pegge

  • Guest
Re: Keywords List?
« Reply #3 on: March 21, 2018, 09:46:12 AM »
That's all I have at present, Mike. Using the same internals, I can expose the core list of primary keywords quite easily, but with secondary keywords, operators and assembler we run into hard-coded groups of keywords, and permutations of keyword endings.

Mike Lobanovsky

  • Guest
Re: Keywords List?
« Reply #4 on: March 21, 2018, 10:34:43 AM »
Can you please point me to the exact respective portions/functions in the source code that are responsible for each group of primary/secondary/asm/operator pieces of O2 vocab? I'd like to evaluate the challenge, if possible.

Charles Pegge

  • Guest
Re: Keywords List?
« Reply #5 on: March 21, 2018, 11:03:30 AM »
I think, start at the bottom with o2link.bas. This contains o2 machine script and linker. Then o2assm.bas" for the assembler. It is part hard-coded, and part hash-coded. The higher level secondary keywords tend to be dispersed over several files, for evaluation inline, so I cannot be precise at the moment.

Mike Lobanovsky

  • Guest
Re: Keywords List?
« Reply #6 on: March 21, 2018, 11:10:13 AM »
Thank you!