]> ocean-lang.org Git - ocean/log
ocean
4 years agoOceani - Jamison Creek Version JamisonCreek-3
NeilBrown [Sat, 18 May 2019 20:46:13 +0000 (06:46 +1000)]
Oceani - Jamison Creek Version

Clean up text and provide new version name.
Additions for this version include:
 - type identifiers
 - arrays and structs
 - global const
 - "and then" "or else" "if .. else"
 - test suite
 - valgrind testing, coverage testing

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani-tests: add tests for str/bool command line args
NeilBrown [Sat, 18 May 2019 15:39:23 +0000 (01:39 +1000)]
oceani-tests: add tests for str/bool command line args

This brings test coverage over 94%

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani: cleanup "sayhello" output
NeilBrown [Sat, 18 May 2019 15:06:34 +0000 (01:06 +1000)]
oceani: cleanup "sayhello" output

This had become unreadable due to the long arrays.
A few other little cleanups and comments.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani: add structs
NeilBrown [Sat, 18 May 2019 14:16:01 +0000 (00:16 +1000)]
oceani: add structs

This is just basic struct support, showing how they
are declared and used.

There is more sophistication to be added such as anonymous
fields and per-field attributes.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani: fix merging of conditionally-scoped variables.
NeilBrown [Sat, 18 May 2019 13:51:24 +0000 (23:51 +1000)]
oceani: fix merging of conditionally-scoped variables.

The problem here was that the list seen in ->in_scope
includes more than just what is currently in-scope.
It also contains things that have been replaced by new instances
of the name.
These can be detected a they aren't the first variable listed
under their name any more.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani-tests: delay valgrind tests
NeilBrown [Sat, 18 May 2019 02:21:55 +0000 (12:21 +1000)]
oceani-tests: delay valgrind tests

As valgrind can be slow, separate the valgrind tests out to
after the main tests.  That was failing that can be found quickly
are found quickly.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani: fix indent for Xval propagate
NeilBrown [Sat, 18 May 2019 00:49:19 +0000 (10:49 +1000)]
oceani: fix indent for Xval propagate

this is double-indented.  I wonder why.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani-tests: test code that has been printed
NeilBrown [Sat, 18 May 2019 00:11:43 +0000 (10:11 +1000)]
oceani-tests: test code that has been printed

Test that the printed code actually works, as well as being re-printable.
Also simplify the messages so they don't use as much space
and fix a typo "exit1" -> "exit 1"

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani: print pre-declared constants when printing program.
NeilBrown [Sat, 18 May 2019 00:01:30 +0000 (10:01 +1000)]
oceani: print pre-declared constants when printing program.

The program is no more than just an 'exec'.  We need to print
the declarations too. As yet, there are only constants.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agoscanner: handle missing newline at EOF
NeilBrown [Fri, 17 May 2019 13:31:48 +0000 (23:31 +1000)]
scanner: handle missing newline at EOF

If there is no newline at EOF, we can see EOF immediately after
a valid symbol.  This can lead to calling close_token() when
state->node is NULL, which crashes.
The code in close_token() only makes sense if state->node is still the
same as token->node.  If it isn't, the token must be at the very end of
its code-node, so a different calculation is needed.

This avoids the NULL deref.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani: add the option for "const" sections
NeilBrown [Mon, 13 May 2019 06:17:12 +0000 (16:17 +1000)]
oceani: add the option for "const" sections

These are introduced with "const" and can define one or
more constants - on one line with ';' or multiple lines
with {} or :

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani: allow list of declarations as top level structure
NeilBrown [Sun, 12 May 2019 05:03:27 +0000 (15:03 +1000)]
oceani: allow list of declarations as top level structure

We can have constants, types, etc at top level, as well
a program

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani: mark code that doesn't need testing.
NeilBrown [Sat, 11 May 2019 01:41:59 +0000 (11:41 +1000)]
oceani: mark code that doesn't need testing.

Some code is included to check and report impossible
conditions.  Failure to exercise this code shouldn't
be seen as a failure of test coverage.
So mark such code as //NOTEST and exclude it
from statistics.

This brings test coverage up to 93%

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani: move "complex types" earlier.
NeilBrown [Sat, 11 May 2019 01:30:30 +0000 (11:30 +1000)]
oceani: move "complex types" earlier.

I think this fits better before "language elements",
as part of "data structures".  Nearly everything it needs
is defined by there.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani: fix valgrind-reported errors.
NeilBrown [Fri, 10 May 2019 10:25:01 +0000 (20:25 +1000)]
oceani: fix valgrind-reported errors.

The test suite wasn't running valgrind in a useful way, and wasn't
actually reporting errors.
So fix it to report leaks and unfreed memory, and then fix the
bugs that it finds.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani tests: check for conflicts.
NeilBrown [Thu, 9 May 2019 12:05:23 +0000 (22:05 +1000)]
oceani tests: check for conflicts.

If the grammar, when analysed as LR1, contains conflicts, then
don't proceed until they are resolved.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agoparsergen: don't report expected shift/reduce conflicts.
NeilBrown [Thu, 9 May 2019 11:59:07 +0000 (21:59 +1000)]
parsergen: don't report expected shift/reduce conflicts.

If a NEWLINE is being treated as a grammar symbol which will sometimes
force a reduction, then an apparent SHIFT/REDUCE conflict that could be
resolved to REDUCE by a newline and would default to shift, is expected
and not really a conflict.  So don't report those.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani: add conditional expression
NeilBrown [Thu, 9 May 2019 11:13:16 +0000 (21:13 +1000)]
oceani: add conditional expression

[value] if [condition] else [alternate value]

is a conditional expression which will only evaluate and return one of
the two values, depending on the condition.
This has lowest precedence of all expressions.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani: add "and then" and "or else"
NeilBrown [Wed, 8 May 2019 10:50:30 +0000 (20:50 +1000)]
oceani: add "and then" and "or else"

"and then" and "or else" are short-circuit versions
of "and" and "or" - they only evaluate second arg if it
is needed.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani-tests: assorted more tests.
NeilBrown [Wed, 8 May 2019 07:22:53 +0000 (17:22 +1000)]
oceani-tests: assorted more tests.

Assorted tests chosen after examining lines of
code that were not being run.
This pushes the coverage over 90% !!!

Also a bugfix - test suites are good !!!

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani-tests: add tests for various type errors.
NeilBrown [Mon, 6 May 2019 08:54:40 +0000 (18:54 +1000)]
oceani-tests: add tests for various type errors.

Now we have test coverage for all tok_err and type_err
calls, and have exceeded 85% total.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani-tests: add tests for various token-errors
NeilBrown [Mon, 6 May 2019 07:57:05 +0000 (17:57 +1000)]
oceani-tests: add tests for various token-errors

This pushes our coverage over 80%

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani-tests: add tests for error cases.
NeilBrown [Mon, 6 May 2019 07:38:17 +0000 (17:38 +1000)]
oceani-tests: add tests for error cases.

Only one test so far, but this infrastructure will be useful
for others.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani-tests: add tests for bad command line args.
NeilBrown [Sun, 5 May 2019 03:25:39 +0000 (13:25 +1000)]
oceani-tests: add tests for bad command line args.

Ensuring the correct behaviour with bad command line args
helps increase coverage.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agomdcode: indent must start with a TAB
NeilBrown [Sun, 5 May 2019 03:18:46 +0000 (13:18 +1000)]
mdcode: indent must start with a TAB

For Makefiles, indent must start with a TAB.  So
insert a TAB if there are 8 or more spaces of indent.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani-tests: add test suite.
NeilBrown [Sun, 5 May 2019 01:56:59 +0000 (11:56 +1000)]
oceani-tests: add test suite.

This is the beginning of a test suite.  It guards
against errors, memory leaks, etc.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agomdcode: don't include blank lines at end of section.
NeilBrown [Sun, 5 May 2019 01:51:08 +0000 (11:51 +1000)]
mdcode: don't include blank lines at end of section.

completely blank lines (no indent) at the end of a section
should not be considered part of that section, but rather
separation between this and the next section.
So don't include them in the code.

When a section is used, for example, as sample output to
test against actual output in a test suit, having the
stray blank at the end can be problematic.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agomdcode: allow a specific section to be extracted.
NeilBrown [Sun, 5 May 2019 01:38:22 +0000 (11:38 +1000)]
mdcode: allow a specific section to be extracted.

Previously, the md2c tool only extracted "File:" sections.
Sometimes we need more control, so allow a second argument
to identify a single section to be extracted.  This will
be written to stdout.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani: add array type.
NeilBrown [Wed, 1 May 2019 09:01:48 +0000 (19:01 +1000)]
oceani: add array type.

I can now declare arrays and access or assign
members there-of.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani: prepare for adding new types with new syntax.
NeilBrown [Wed, 1 May 2019 08:22:38 +0000 (18:22 +1000)]
oceani: prepare for adding new types with new syntax.

1/ 'Variable' now returns an 'exec', so other things returning
   and 'exec' can be the LHS of an assignment.
2/ provide forward-decls of generic functions so that
   new type functions can use them to work with
   components of the types.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani: add "remainder" operator.
NeilBrown [Wed, 1 May 2019 08:13:21 +0000 (18:13 +1000)]
oceani: add "remainder" operator.

a % b
treats a and b as integers, does a division, and reports
the remainder.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani: add some support for lvalues.
NeilBrown [Tue, 30 Apr 2019 06:24:09 +0000 (16:24 +1000)]
oceani: add some support for lvalues.

New linterp_exec() returns an lvalue, (pointer to value)
and individual cases can provide either an lvalue or an rvalue.

This means the RHS of assignment might not be a simple variable,
so we leave the "v = v->merged" part to the "interp exec" for Xvar.
Also, linterp_exec() might return NULL, so be careful.
This might happen, e.g., when an array index is out of bounds.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani: fix up test program.
NeilBrown [Tue, 30 Apr 2019 06:23:21 +0000 (16:23 +1000)]
oceani: fix up test program.

The messages being printed didn't make sense - weird.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani: delay constant assignment test to type analysis.
NeilBrown [Tue, 30 Apr 2019 04:00:03 +0000 (14:00 +1000)]
oceani: delay constant assignment test to type analysis.

When we get more complex types, it will be easier to
guard against assigning to a constant during type analysis.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani: allow a type to control how it is printed.
NeilBrown [Sun, 28 Apr 2019 04:08:23 +0000 (14:08 +1000)]
oceani: allow a type to control how it is printed.

this is needed for e.g. printing the program when there
are declared types.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani: delegate type compatability to type.
NeilBrown [Sun, 28 Apr 2019 03:45:26 +0000 (13:45 +1000)]
oceani: delegate type compatability to type.

Rename vtype_compat to type_compat, and have it
call the ->compat function if the required type
provides it.
Otherwise require type equivalence.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani: introduce type->prepare()
NeilBrown [Sun, 28 Apr 2019 03:10:15 +0000 (13:10 +1000)]
oceani: introduce type->prepare()

During parsing and analysis we don't want to "init" a
variable as that can allocate memory - when we add arrays,
we might not know yet how much memory.

So introduce 'prepare' to prepare a value - such that calling
free on it will work - without allocating.

'init' is then called when a variable is declared - unless something
is assigned to it instead.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani: disallow assignment if no 'dup' operation.
NeilBrown [Sun, 28 Apr 2019 01:10:03 +0000 (11:10 +1000)]
oceani: disallow assignment if no 'dup' operation.

'dup' is needed for assignment, so if it isn't present
it must be forbidden.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani: allow a variable to be declared with no value
NeilBrown [Sun, 28 Apr 2019 00:40:12 +0000 (10:40 +1000)]
oceani: allow a variable to be declared with no value

 var:type

is now allowed.  "var:" is not - there must be either a
type or an initial value.

If only the type is given, the type's 'init' function
is called to provide an initial value.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani: := is no longer a token.
NeilBrown [Sun, 28 Apr 2019 00:24:38 +0000 (10:24 +1000)]
oceani: := is no longer a token.

It was always intended that a type could come between
the : and = of a declaration.
It makes more sense, and simplifies the grammar, if
we stop treating  := as ever being a token.
So now : and = are separate tokens.
If the parse sees ":=", it will happily treat that
as two separate tokens, which is what we want.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani: make "Base Types" a subsection of "Types"
NeilBrown [Sat, 27 Apr 2019 23:21:06 +0000 (09:21 +1000)]
oceani: make "Base Types" a subsection of "Types"

I don't think it deserved to stand alone.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani: move free_value() to the other generic value code.
NeilBrown [Sat, 27 Apr 2019 23:19:44 +0000 (09:19 +1000)]
oceani: move free_value() to the other generic value code.

This doesn't belong wit the base types.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani - assorted cleanups.
NeilBrown [Mon, 22 Apr 2019 12:01:06 +0000 (22:01 +1000)]
oceani - assorted cleanups.

Reading through the whole document found a few typos,
and few things in the wrong place, some areas where
a better explanation would help etc.

This patch combines several such improvements.

Signed-off-by: NeilBrown <neil@brown.name>
4 years agooceani: initial support for named types.
NeilBrown [Mon, 22 Apr 2019 01:17:03 +0000 (11:17 +1000)]
oceani: initial support for named types.

The base types are now stored in a symbol table (linked list)
and can be fetched by name.
  name:type = value

now works to declare 'name' as of the given type.

The narrative needs to be improved to include a clear
section on types, and variable declarations of the form
   name:type

with no assignment still need to be added.

Signed-off-by: NeilBrown <neil@brown.name>
5 years agooceani: make set of types extensible.
NeilBrown [Sat, 20 Apr 2019 06:18:18 +0000 (16:18 +1000)]
oceani: make set of types extensible.

Rather than a enum listing allowed types, we now
have a 'struct type' which can contain any type.
For now it just has an enum and function pointer
to the existing function, but that can be extended.

Signed-off-by: NeilBrown <neil@brown.name>
5 years agooceani: fix a couple of typos.
NeilBrown [Sat, 20 Apr 2019 04:57:21 +0000 (14:57 +1000)]
oceani: fix a couple of typos.

There is always one more typo...

Signed-off-by: NeilBrown <neil@brown.name>
5 years agooceani: discard Vnolabel infavour of rules.
NeilBrown [Sat, 20 Apr 2019 04:40:52 +0000 (14:40 +1000)]
oceani: discard Vnolabel infavour of rules.

Instead Vnolabel as a type, change "bool_permitted" to
a set of rules (Rboolok) and add a new rule: Rnolabel.

This requires changes to type_err() and elsewhere.

Signed-off-by: NeilBrown <neil@brown.name>
5 years agooceani: don't store 'tail' in 'struct value'.
NeilBrown [Tue, 2 Apr 2019 01:36:35 +0000 (12:36 +1100)]
oceani: don't store 'tail' in 'struct value'.

It is never used so there isn't much point
storing it.  If/When we do use it, we'll
parse it immediately and store the meaning.
And in any case, it should be char[3].

Signed-off-by: NeilBrown <neil@brown.name>
5 years agooceani.mdc: fix assorted typos.
NeilBrown [Fri, 22 Mar 2019 09:23:59 +0000 (20:23 +1100)]
oceani.mdc: fix assorted typos.

Little errors mostly.

Signed-off-by: NeilBrown <neil@brown.name>
6 years agooceani: detect and report tails on numbers and strings. StoneyCreek StoneyCreek-2
NeilBrown [Mon, 19 Feb 2018 06:48:44 +0000 (17:48 +1100)]
oceani: detect and report tails on numbers and strings.

Currently illegal, so we should say so.

Signed-off-by: NeilBrown <neil@brown.name>
6 years agoscanner: capture the tail of a string.
NeilBrown [Mon, 19 Feb 2018 06:47:00 +0000 (17:47 +1100)]
scanner: capture the tail of a string.

A string can have a tail,
   "hello"xy

where the "xy" might one day have a meaning (utf8? utf16??).

We should capture that.

Signed-off-by: NeilBrown <neil@brown.name>
6 years agooceani: track where each variable was declared.
NeilBrown [Mon, 19 Feb 2018 06:08:11 +0000 (17:08 +1100)]
oceani: track where each variable was declared.

This allows better error messages when they are
redeclared.

Signed-off-by: NeilBrown <neil@brown.name>
6 years agooceani: minimal error tracking.
NeilBrown [Mon, 19 Feb 2018 05:58:40 +0000 (16:58 +1100)]
oceani: minimal error tracking.

1/ If the parser hits an error, catch it at eof by having
    Program -> ERROR
2/ Allow the presence of and error to be recorded in the context.
3/ If an error occured, don't try to run, and do exit with an error
   status.

Now, at last, we get told where the error was.

Signed-off-by: NeilBrown <neil@brown.name>
6 years agooceani: handle NULL from parse_oceani()
NeilBrown [Mon, 19 Feb 2018 05:54:03 +0000 (16:54 +1100)]
oceani: handle NULL from parse_oceani()

If the parsed finds nothing, it will return a pointer
to a NULL.  We need to be careful not to deref this
in printing, analysis, or execution.

Signed-off-by: NeilBrown <neil@brown.name>
6 years agooceani: Expression etc should be 'exec', not 'binode'.
NeilBrown [Mon, 19 Feb 2018 05:46:04 +0000 (16:46 +1100)]
oceani: Expression etc should be 'exec', not 'binode'.

As a 'var' and a 'val' are possible expressions,
'binode' isn't correct.  This is obvious when you
consider that I needed to case $1 for a var or var
before assigning it to $0 for Factor -> Value etc.

So change all these to expect the more generic 'struct exec *'.

Without this change, error handling can try to free a var as though it
was a binode, and get into trouble.

Signed-off-by: NeilBrown <neil@brown.name>
6 years agoparsergen: enable error handling.
NeilBrown [Mon, 19 Feb 2018 05:40:06 +0000 (16:40 +1100)]
parsergen: enable error handling.

The error handling code currently aborts early because
it was badly broken.
After recent changes it works well enough for experimenting,
so remove the exit(1) and other unnecessary code, and
let's experiment.

Signed-off-by: NeilBrown <neil@brown.name>
6 years agoparsergen: improve symbol-discard in error handling.
NeilBrown [Mon, 19 Feb 2018 05:38:12 +0000 (16:38 +1100)]
parsergen: improve symbol-discard in error handling.

As we don't keep the full look-ahead set, we need to pay a
bit more attention when discarding input symbols, looking
for one we recognize.  We need to consider anything
that can be shifted in any state we can reach by simple
shifting.

Signed-off-by: NeilBrown <neil@brown.name>
6 years agoparsergen: be careful shifting TK_error
NeilBrown [Mon, 19 Feb 2018 05:31:14 +0000 (16:31 +1100)]
parsergen: be careful shifting TK_error

shift() behaved a little differently when p.tos == 0,
and if the stack is completely empty, there is little
point trying to shift TK_error as there is no state
to work with.

So rearrange the loop slightly.

Signed-off-by: NeilBrown <neil@brown.name>
6 years agoparsergen: document min_prefix and starts_line.
NeilBrown [Mon, 19 Feb 2018 05:23:27 +0000 (16:23 +1100)]
parsergen: document min_prefix and starts_line.

Signed-off-by: NeilBrown <neil@brown.name>
6 years agoparsergen: remove symbol synthesis option.
NeilBrown [Mon, 19 Feb 2018 04:32:46 +0000 (15:32 +1100)]
parsergen: remove symbol synthesis option.

This idea never worked, and cannot work as we cannot
magically synthesis the ast node to go with a synthesized
symbol.
If we want to synthesize something on error, we just use
a production like
   foo -> ERRROR ${ $0 = a_new_for(); }$

Signed-off-by: NeilBrown <neil@brown.name>
6 years agoscanner: fix calculation of column.
NeilBrown [Sun, 18 Feb 2018 05:10:59 +0000 (16:10 +1100)]
scanner: fix calculation of column.

When we stripe the expected indent from the
start of each line, we need to update 'col'
to correctly account for tabs.
Previous code effectively assumed tabs were 4 spaces.

Signed-off-by: NeilBrown <neil@brown.name>
6 years agoscanner: improve text and fix typos.
NeilBrown [Sun, 18 Feb 2018 05:10:12 +0000 (16:10 +1100)]
scanner: improve text and fix typos.

Improve the text about 'marks' to explain the difficulty
with comments and '/'.
Fix a few typos.

Signed-off-by: NeilBrown <neil@brown.name>
6 years agooceani - add error reporting for type errors
NeilBrown [Sat, 17 Feb 2018 08:20:53 +0000 (19:20 +1100)]
oceani - add error reporting for type errors

This is still rough, but it is at least a
basis to work on.

Signed-off-by: NeilBrown <neil@brown.name>
6 years agoscanner: fix silly error calling indent_tab()
NeilBrown [Sat, 17 Feb 2018 08:19:34 +0000 (19:19 +1100)]
scanner: fix silly error calling indent_tab()

Wrong sort of value is passed.

Signed-off-by: NeilBrown <neil@brown.name>
6 years agooceani: pass parse_context through propagate_types
NeilBrown [Sat, 17 Feb 2018 08:02:57 +0000 (19:02 +1100)]
oceani: pass parse_context through propagate_types

This will allow more context for error messages.

Signed-off-by: NeilBrown <neil@brown.name>
6 years agooceani: fix type analysis for 'while' condition.
NeilBrown [Sat, 17 Feb 2018 01:01:08 +0000 (12:01 +1100)]
oceani: fix type analysis for 'while' condition.

The condition in a 'while' can always return Bool,
or may return some other consistent type.
This requires extra subtlety in analysis.

Signed-off-by: NeilBrown <neil@brown.name>
6 years agoNew lang: Stoney Creek
NeilBrown [Wed, 31 Jan 2018 03:25:16 +0000 (14:25 +1100)]
New lang: Stoney Creek

This is the second iteration of language design.
it adds scopes variables.
Variables must be declared before use, but they
can be declared in both branches of an 'if', then
used afterwards as the one variable.

No hole-in-scope is allowed: names that are declared
cannot be redeclared in a subordinate scope.

A test program is included:
   make sayhello

Note that there are no useful error messages yet.
That is the next step.

Signed-off-by: NeilBrown <neil@brown.name>
6 years agoscanner: fix parsing of comments.
NeilBrown [Sun, 11 Feb 2018 08:07:55 +0000 (19:07 +1100)]
scanner: fix parsing of comments.

If '/' is a known mark, then "//" and "/*" comments don't get
parsed properly.  Add handling for this case.

Signed-off-by: NeilBrown <neil@brown.name>
6 years agoparsergen.mdc: add precedence handling
NeilBrown [Mon, 29 Jan 2018 05:20:01 +0000 (16:20 +1100)]
parsergen.mdc: add precedence handling

This hasn't been documented properly in the text yet, but
the example has been changed to work and it seems good.

There is no support for precedence to select between two
reductions because I don't believe that ever happens :-) and
I haven't done anything special for non-associative because
I don't know what I would do.

Signed-off-by: NeilBrown <neil@brown.name>
6 years agoparsergen: record line number of reduce fragments.
NeilBrown [Tue, 6 Feb 2018 05:42:01 +0000 (16:42 +1100)]
parsergen: record line number of reduce fragments.

If there is an error in a code fragment used to handle
a 'reduce' action, we need the compiler to report the
correct line from the grammar file.
This information is easily available from the scanner,
we just need to pass it along.

Signed-off-by: NeilBrown <neil@brown.name>
6 years agooceani/parsergen: assorted text improvements.
NeilBrown [Mon, 29 Jan 2018 07:29:03 +0000 (18:29 +1100)]
oceani/parsergen: assorted text improvements.

Mostly typo fixes with a few improvements to clarity
or content.

Signed-off-by: NeilBrown <neil@brown.name>
9 years agooceani.mk: make sure libstring.o gets built
NeilBrown [Tue, 17 Feb 2015 03:25:36 +0000 (14:25 +1100)]
oceani.mk: make sure libstring.o gets built

There is probably a nicer way to do this, but this seems to work.

Signed-off-by: NeilBrown <neil@brown.name>
9 years agoMore new files to .gitignore FallsCreek FallsCreek-1
NeilBrown [Mon, 13 Oct 2014 01:20:54 +0000 (12:20 +1100)]
More new files to .gitignore

Signed-off-by: NeilBrown <neil@brown.name>
9 years agooceani: propagate_types should ignore NULL better.
NeilBrown [Mon, 13 Oct 2014 01:17:37 +0000 (12:17 +1100)]
oceani: propagate_types should  ignore NULL better.

A 'NULL' is an empty statement (e.g. 'skip') or something else
that is expected to be absent, like the left-hand-side of a unary operator.

So report that it returns Vnone, but don't worry about what is
expected.

Signed-off-by: NeilBrown <neil@brown.name>
9 years agooceani: accept newlines at start of {block}
NeilBrown [Sun, 12 Oct 2014 23:39:06 +0000 (10:39 +1100)]
oceani: accept newlines at start of {block}

This  is needed for

~~~~~~
program {
code
}
~~~~~~

to work.

Signed-off-by: NeilBrown <neil@brown.name>
9 years agooceani: accept MULTI_STRING as well as STRING
NeilBrown [Sun, 12 Oct 2014 23:38:05 +0000 (10:38 +1100)]
oceani: accept MULTI_STRING as well as STRING

The scanner produces two types of strings - we need to accept
them both.

Signed-off-by: NeilBrown <neil@brown.name>
9 years agooceani: allow number of command line to be negative.
NeilBrown [Sun, 12 Oct 2014 23:36:39 +0000 (10:36 +1100)]
oceani: allow number of command line to be negative.

number_parse doesn't expect leading sign, so handle it explicitly.

Signed-off-by: NeilBrown <neil@brown.name>
9 years agoParsergen: abort on error.
NeilBrown [Sun, 12 Oct 2014 23:35:06 +0000 (10:35 +1100)]
Parsergen: abort on error.

The error handling is currently completely broken and goes
into an infinite loop.
Just abort for now.

Signed-off-by: NeilBrown <neil@brown.name>
9 years agooceani: don't try to print a 'then' clause for a switch.
NeilBrown [Sat, 11 Oct 2014 06:07:25 +0000 (17:07 +1100)]
oceani: don't try to print a 'then' clause for a switch.

'switch' doesn't have a 'then', so don't try to print it.

Signed-off-by: NeilBrown <neil@brown.name>
9 years agooceani: memdup argument strings when assigning to a variable.
NeilBrown [Sat, 11 Oct 2014 06:04:11 +0000 (17:04 +1100)]
oceani: memdup argument strings when assigning to a variable.

string values are assumed to be in malloced memory, so
when assigning a string from the command line, copy it to malloced
memory.

Signed-off-by: NeilBrown <neil@brown.name>
9 years agooceani: remove the 'style' link
NeilBrown [Fri, 10 Oct 2014 06:46:06 +0000 (17:46 +1100)]
oceani: remove the 'style' link

Signed-off-by: NeilBrown <neil@brown.name>
9 years agooceani: add proper 'then' handling.
NeilBrown [Tue, 7 Oct 2014 06:06:11 +0000 (17:06 +1100)]
oceani: add proper 'then' handling.

I hadn't thought about this properly before..

Signed-off-by: NeilBrown <neil@brown.name>
9 years agooceani: initial interpreted for "ocean".
NeilBrown [Fri, 3 Oct 2014 05:54:03 +0000 (15:54 +1000)]
oceani: initial interpreted for "ocean".

This is a very preliminary interpreter for a preliminary
language which is building towards being "ocean".
I call this the "Falls Creek" version.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agopargergen: typo: i, not 1. workingparser
NeilBrown [Tue, 7 Oct 2014 06:05:20 +0000 (17:05 +1100)]
pargergen: typo: i, not 1.

This makes some newline handling break.

Signed-off-by: NeilBrown <neil@brown.name>
9 years agoparsergen: update description to match current reality.
NeilBrown [Fri, 3 Oct 2014 04:52:16 +0000 (14:52 +1000)]
parsergen: update description to match current reality.

In partcular, the handling of indents and newlines was a
bit out-dated.

Signed-off-by: NeilBrown <neil@brown.name>
9 years agoparsergen: remove special casing for pop(0).
NeilBrown [Fri, 3 Oct 2014 04:30:36 +0000 (14:30 +1000)]
parsergen: remove special casing for pop(0).

If pop() is asked to remove nothing from the stack, it now
does exactly the right thing and returns the value that we want.
So some special-casing can be removed.

Signed-off-by: NeilBrown <neil@brown.name>
9 years agoindent_test: integrate into Makefile scheme nicely.
NeilBrown [Fri, 3 Oct 2014 04:01:45 +0000 (14:01 +1000)]
indent_test: integrate into Makefile scheme nicely.

The test code is now included in indent_test.mdc,
and there is a '.mk'.
  make tests

will run the test.

Signed-off-by: NeilBrown <neil@brown.name>
9 years agoparsergen: update doc for change from 'starts line' to 'line like'
NeilBrown [Fri, 3 Oct 2014 03:37:17 +0000 (13:37 +1000)]
parsergen: update doc for change from 'starts line' to 'line like'

Signed-off-by: NeilBrown <neil@brown.name>
9 years agoparse trace: report since_newline rather than newline_permitted
NeilBrown [Fri, 3 Oct 2014 03:29:42 +0000 (13:29 +1000)]
parse trace: report since_newline rather than newline_permitted

The number in newline_permitted isn't interesting.
The number in since_newline is.  So print that.

Signed-off-by: NeilBrown <neil@brown.name>
9 years agoindent test: various fixed to match new design.
NeilBrown [Fri, 3 Oct 2014 03:29:14 +0000 (13:29 +1000)]
indent test: various fixed to match new design.

Signed-off-by: NeilBrown <neil@brown.name>
9 years agoparsergen: revise rule for NEWLINE forcing reduce
NeilBrown [Fri, 3 Oct 2014 03:28:32 +0000 (13:28 +1000)]
parsergen: revise rule for NEWLINE forcing reduce

If the whole line is a single symbol, then it isn't appropriate
for a NEWLINE to force a reduce (it may be for an OUT, but as the
NEWLINE shifts (the OUT doesn't) we don't need to push so hard).

Signed-off-by: NeilBrown <neil@brown.name>
9 years agoparsergen: fix incorrect 'newline_permitted' setting.
NeilBrown [Fri, 3 Oct 2014 03:28:05 +0000 (13:28 +1000)]
parsergen: fix incorrect 'newline_permitted' setting.

If a state 'starts_line', then a newline is explicitly permitted
(once indents have gone), not explicitly denied!

Signed-off-by: NeilBrown <neil@brown.name>
9 years agoparsegen: pop was not computing start_of_line properly.
NeilBrown [Fri, 3 Oct 2014 03:27:40 +0000 (13:27 +1000)]
parsegen: pop was not computing start_of_line properly.

In there is any line start in the sequence being popped,
then the new symbol is considered to start a line.

Signed-off-by: NeilBrown <neil@brown.name>
9 years agoparsergen: get rid of 'next' in parser_run()
NeilBrown [Fri, 3 Oct 2014 03:26:33 +0000 (13:26 +1000)]
parsergen: get rid of 'next' in parser_run()

It isn't used for anything useful any more.

Signed-off-by: NeilBrown <neil@brown.name>
9 years agoparsergen: next.indents in parser_run is always zero.
NeilBrown [Fri, 3 Oct 2014 03:26:00 +0000 (13:26 +1000)]
parsergen: next.indents in parser_run is always zero.

now that indents are counted with the previous symbol,
next.indents is always zero.  So stop using it or updating it.

Signed-off-by: NeilBrown <neil@brown.name>
9 years agoparsergen: don't pass full frame to parser_trace()
NeilBrown [Fri, 3 Oct 2014 03:25:25 +0000 (13:25 +1000)]
parsergen: don't pass full frame to parser_trace()

parser_trace() only uses 2 fields, so only pass those.

Signed-off-by: NeilBrown <neil@brown.name>
9 years agoparsergen: don't use 'frame' to pass args to shift() or receive from pop()
NeilBrown [Fri, 3 Oct 2014 03:24:36 +0000 (13:24 +1000)]
parsergen: don't use 'frame' to pass args to shift() or receive from pop()

'struct frame' holds a number of fields that shift()
ignores and pop() doesn't fill in.
So it is a bit confusing to see a frame passed in
and mostly ignored.

So just pass in the fields that are actually needed.
This fixes a bug where 'since_newline' was set wrongly when a newline
is shifted.

Signed-off-by: NeilBrown <neil@brown.name>
9 years agoparsergen: fix handling of Newline in parse.
NeilBrown [Fri, 3 Oct 2014 03:22:29 +0000 (13:22 +1000)]
parsergen: fix handling of Newline in parse.

The required handling for 'newline' when not ignored is:

    if the current state can REDUCE and the reduction length is no
    more symbols than the frames-since-start-of-line count, we REDUCE.

'can REDUCE' removes "reduce_size >= 0", not ">".
'not more symbols' means "reduce_size <= tos->since_newline", not "<".

Signed-off-by: NeilBrown <neil@brown.name>
9 years agoparsergen: fix handling of TK_in during parse.
NeilBrown [Thu, 2 Oct 2014 11:01:41 +0000 (21:01 +1000)]
parsergen: fix handling of TK_in during parse.

Now that an 'in'  it always considered to be *after* a symbol,
we want to apply 'in' token to the current top-of-stack, not to the
'next' frame.

Signed-off-by: NeilBrown <neil@brown.name>
9 years agoparsergen: remove starts_indented.
NeilBrown [Thu, 2 Oct 2014 10:59:55 +0000 (20:59 +1000)]
parsergen: remove starts_indented.

This is no longer used.

Signed-off-by: NeilBrown <neil@brown.name>