CodeWorker



Changes on version 3.2
Date Type Caller Description
22nov2003 feature - The BNF directive #trace traces the resolution steps of an extended–BNF script.

Hit a key to interrupt the display of trace information and to pause the controlling sequence.

22nov2003 function -
  • function inputKey(echo : bool) : string
    ParameterTypeDescription
    echoboolasks for echoing the standard input on the console

    Returns a character extracted from the standard input, the keyboard generally. If no key was pressed, it returns an empty string.

    See statement modifiers file_as_standard_input (file as standard input) and string_as_standard_input (string as standard input) to change the source of the standard input.

    If the source of the standard input is the keyboard, the argument echo has no effects. Otherwise, the input text is displayed into the console only if echo is worth true.

20nov2003 bug_fix Gwenael CHAZAL CodeWorker crashed when an expression was passed to a node parameter of any non–terminal BNF symbol, instead of passing a tree node. Now, it raises an error.
20nov2003 feature Maxime BOURGET A BNF symbol resolved with success, has accepted the assignment of its scanned portion of sentence to a variable for a long time: B:v means that the text covered by B is assigned to v.

Now, you can specify to concatenate the covered text to the ancient value of the variable: B:+v.

Example:
If v is worth "nebula:" and if the sentence starts with "Orion.", then v becomes "nebula:Orion" after the resolution of #readIdentifier:+v.

20nov2003 improvement - The template functions accept a template–based script to define their body. The specialization of a function for a given template instantiation key is resolved at runtime.

Example:

function f(x : node) {/*is a synonym of f<"">(x : node)*/}

function f<T>(x : node) {{
      // ‘{{‘ announces a template–based script, which
      // will generate the correct implementation during the instantiation
      insert x.@T@ = "@T@";
      f<"@T.rsubString(1)@">(x);
@
      // ‘}}‘ announces the end of the template–based script
}}

f<"field">(project);
traceObject(project);

Output:

Tracing variable ‘project‘:
      field = "field"
      fiel = "fiel"
      fie = "fie"
      fi = "fi"
      f = "f"
End of variable‘s trace ‘project‘.

19nov2003 improvement - The engine has improved the compilation‘s speed of scripts.
17nov2003 feature Maxime BOURGET A new BNF binary operator ‘|>‘ was added.

The sequence A |> B is understood as considering the sub sentence scanned by A, which delimits the portion of text left visible to B. B starts scanning at the beginning of the sub sentence covered by A and cannot go beyond.

When the operator has achieved with success, the cursor points to the end of the sub sentence covered by A.

You‘ll find below the different steps processed by the operator:

  • the BNF literal A is executed,
  • if success, the cursor comes back to the beginning of the sub sentence covered by A
  • then, B is executed, knowing that the operator forces the end of the sub sentence where A had finished,
  • if success, the cursor points to the end of A, even if B hadn‘t scan up to the end of the sentence.

Example:

We want to recognize all colons present on a line. The sub sentence we would like to scan is a line: –>‘\n‘. Recognizing colons is like: [–>‘:‘]*, which asks for jumping from a colon to another, without considering the end of line.
–>‘\n‘ |> [–>‘:‘]* restricts the colon recognition to the line.

17nov2003 improvement Maxime BOURGET The BNF operator ‘–>‘ admits a syntax extension, for the adjustment of its internal mechanism.

–>A jumps just after the the first matching of A in the sentence. It processes the equivalent piece of extended–BNF script:

=> local iLocation;
~[A => iLocation = getInputLocation();]*
=> setInputLocation(iLocation);

To intervene on the boundaries of the repeated sequence [A ...]*, an extension was added to the syntax: –>boundaries A, where boundaries gives the multiplicity of the bracketed sequence (‘?‘, ‘+‘, ‘2..*‘, #repeat(iBegin, iEnd) ...).
Note: the boundaries must be declared just after the arrow.

The text covered by –>A includes the unmatched characters plus the sub sentence scanned by A, so –>A:v assigns the complete covered text to the variable v. This is sometimes a drawback: perhaps do you want to take the unmatched character or the sub sentence scanned by A.
So now, you can specify the variables intended to receive these intermediate values:
–>(:varBefore –:varAfter)A:varTotal
Note: the intermediate variables are declared just before the BNF symbol A, after the boundaries if any.

Example:
We will apply [–>(:varBefore –:varAfter) #readNumeric]:varTotal on the sentence "Garfield.laziness 99.99 percent":

  • varBefore = "Garfield.laziness "
  • varAfter = "99.99"
  • varTotal = "Garfield.laziness 99.99"

The last extension brought to the jump operator –>A is to allow the execution of a BNF sequence at the beginning of the sub sequence matched by A. This BNF sequence is declared into the parenthesis used for the intermediate variables, behind these variables, if any:
–>(:varBefore –:varAfter B)A
The advantage of infiltrating the BNF sequence B is that the intermediate variables are populated, and that the cursor doesn‘t point after the matching of A yet, but at the beginning of the sub sentence matched by A.

15nov2003 function Maxime BOURGET
  • function getVariableAttributes(variable : treereflist : tree) : int
    ParameterTypeDescription
    variabletreerefthe variable to explore
    listtreewill contain the name and type (reference to another node or not) of each attribute

    Populates a list with all attribute names of a tree node. The name of branches just below the node variable are put into list.

    The attribute‘s name is a key in the list and there is no value assigned to the item, except for attributes that point to another node (a reference). In that case, the item is worth the complete name of the referenced node.

    The function returns the number of attributes found, or a negative value (–1) if the tree node variable doesn‘t exist.

    Note: use #evaluateVariable() to navigate along a tree node, where the complete name is determined at runtime.