Skip to content

Primitives #5

@iliabylich

Description

@iliabylich

I think we need an abstraction of Vec<T>:

  1. There's a node_list_t type that stores an array of node pointers. Is it intentional? For better locality it should be an array of nodes (i.e. node * instead of node **).
  2. There's a stack of string literals that has fixed size, so this is another place where we need Vec
  3. We will need a stack of sets of local variables
  4. We will need a stack of "current attribute"s to distinguish errors like in def foo(bar = bar) from def foo(bar = def foo(x = bar); end); end
  5. We need a stack of nested contexts (module in class in method in defined etc) to know where we are during parsing.
  6. We need a stack of numparams to handle nested procs/lambdas with numbered parameters
  7. We need 2 stacks for pattern matching: one to track uniq items in a list, one to track uniq keys in a hash pattern

Also I noticed that nodes encapsulate tokens, is it intentional? There are cases when node needs a value that is based on token, but is slightly different:

  1. in foo.bar = baz method name should be "bar="
  2. in foo.(bar) method name is "call"
  3. in -foo method name is "-@" (same with "+")
  4. unary operators on numeric literals can include sign in their value for simplicity (i.e. "-42" should be Int("-42"))
  5. ... and maybe more.

I think it makes sense to extract a type string_t:

typedef struct {
  char *start;
  char *end;
} string_t;

WDYT?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions