update doc comment and code formatting

This commit is contained in:
a-Sansara 2018-07-31 22:06:14 +02:00
parent 62419bf3f7
commit 019a875d79
5 changed files with 65 additions and 57 deletions

View File

@ -3,8 +3,7 @@ using Gee;
using Pluie;
/**
* a class to read file line by line with convenient methods to rewind to specific lines
* using {@link Io.StreamLineMark}
* Yaml Event class
*/
public class Pluie.Yaml.Event
{

View File

@ -3,8 +3,7 @@ using Gee;
using Pluie;
/**
* a tiny Yaml Parser whose purpose is not to comply with all yaml specifications but to parse yaml configuration files
* todo improve description of what is expected
* a Yaml Loader class
*/
public class Pluie.Yaml.Loader
{
@ -13,6 +12,9 @@ public class Pluie.Yaml.Loader
*/
Yaml.Scanner scanner { public get; internal set; }
/**
* indicate if file has been sucessfully loaded
*/
public bool done { get; internal set; }
/**
@ -22,6 +24,8 @@ public class Pluie.Yaml.Loader
/**
* @param path the path of file to parse
* @param displayFile display original file
* @param displayNode display corresponding Yaml Node Graph
*/
public Loader (string path, bool displayFile = false, bool displayNode = false )
{
@ -37,7 +41,7 @@ public class Pluie.Yaml.Loader
}
/**
*
* return resulting Yaml root node
*/
public Yaml.NodeRoot get_nodes ()
{
@ -45,7 +49,7 @@ public class Pluie.Yaml.Loader
}
/**
*
* display original file
*/
public void displayFile ()
{

View File

@ -3,20 +3,19 @@ using Gee;
using Pluie;
/**
* a tiny Yaml Parser whose purpose is not to comply with all yaml specifications but to parse yaml configuration files
* todo improve description of what is expected
* a class dealing with a sequence of yaml events and composing the Yaml Node Graph
*/
public class Pluie.Yaml.Processor
{
/**
* indicate if file has been sucessfully parsed
* indicates if processing is sucess
*/
public bool done;
/**
* Events list
*/
public Gee.LinkedList<Yaml.Event> events { get; internal set; }
public Gee.ArrayList<Yaml.Event> events { get; internal set; }
/**
* Anchor map
@ -53,12 +52,12 @@ public class Pluie.Yaml.Processor
*/
public Processor ()
{
this.events = new Gee.LinkedList<Yaml.Event>();
this.events = new Gee.ArrayList<Yaml.Event>();
this.anchors = new Gee.HashMap<string, Yaml.Node>();
}
/**
*
* display the list of events generated via yaml.c
*/
public void read ()
{
@ -77,13 +76,14 @@ public class Pluie.Yaml.Processor
}
stdout.printf (" }");
}
stdout.printf("]\n");
of.echo ("]\n");
}
}
/**
*
* retriew the next Yaml Event
* @param the iterator
*/
private Yaml.Event? next_event (Iterator<Yaml.Event> it)
{
@ -95,7 +95,8 @@ public class Pluie.Yaml.Processor
}
/**
*
* retriew the next Yaml Value Event closest to Key Event
* @param the iterator
*/
private Yaml.Event? get_value_key_event (Iterator<Yaml.Event> it)
{
@ -108,7 +109,8 @@ public class Pluie.Yaml.Processor
}
/**
*
* retriew the next Yaml Value Event
* @param the iterator
*/
private Yaml.Event? get_value_event (Iterator<Yaml.Event> it)
{
@ -121,7 +123,7 @@ public class Pluie.Yaml.Processor
}
/**
*
* processing the events list and generate the corresponding Yaml Nodes
*/
public bool run ()
{

View File

@ -4,17 +4,37 @@ using Pluie;
extern void yaml_parse_file(string srcPath, string destPath);
/**
* a tiny Yaml Parser whose purpose is not to comply with all yaml specifications but to parse yaml configuration files
* todo improve description of what is expected
* a Yaml scanner class dealing with libyaml to generate a list of Yaml.Event
*/
public class Pluie.Yaml.Scanner
{
/**
* Regex pattern use to find EVENT
*/
const string REG_EVENT = "^([0-9]+), ([0-9]+)(.*)$";
/**
* Regex pattern use to find EVENT VERSION
*/
const string REG_VERSION = "^, ([0-9]+), ([0-9]+)$";
/**
* Regex pattern use to find EVENT TAG
*/
const string REG_TAG = "^, \"([^\"]*)\", \"([^\"]*)\"$";
/**
* Regex pattern use to find EVENT ERROR
*/
const string REG_ERROR = "^, \"([^\"]*)\"$";
/**
* Regex pattern use to find EVENT SCALAR
*/
const string REG_SCALAR = "^, ([0-9]+), \"(.*)\"$";
/**
* Regex pattern use to find EVENT ANCHOR
*/
const string REG_ANCHOR = "^, \"([^\"]*)\"$";
/**
* Regex pattern use to find EVENT ALIAS
*/
const string REG_ALIAS = "^, \"([^\"]*)\"$";
/**
@ -43,27 +63,22 @@ public class Pluie.Yaml.Scanner
enum MIEVT_ERROR { NONE, DATA }
/**
* indicate if file has been sucessfully parsed
* indicate if file has been sucessfully scanned
*/
public bool done { get; internal set; }
/**
* the mark use to rewind line throught Io.Reader
*/
Io.StreamLineMark? mark;
/**
* Reader used to load content yaml file
*/
Io.Reader reader;
/**
* Yaml Processor
* Yaml Processor used to process events
*/
Yaml.Processor processor { get; internal set; }
/**
* @param path the path of file to parse
* @param path the path of file to scan
*/
public Scanner (string path)
{
@ -73,7 +88,7 @@ public class Pluie.Yaml.Scanner
}
/**
*
* return resulting Yaml root node
*/
public Yaml.NodeRoot get_nodes ()
{
@ -81,13 +96,13 @@ public class Pluie.Yaml.Scanner
}
/**
* parse a file related to specifiyed path
* @param path the path to parse
* scan specifiyed file generated throught yaml.c
* @param optional file path to scan
*/
public bool run (string? path = null)
{
Dbg.in (Log.METHOD, "path:'%s'".printf (path), Log.LINE, Log.FILE);
if (path != null) {
if (path != null && this.reader.path != path) {
this.reader.load (path);
}
else {
@ -123,10 +138,9 @@ public class Pluie.Yaml.Scanner
data.set("major", mi.fetch (MIEVT_VERSION.MAJOR));
data.set("minor", mi.fetch (MIEVT_VERSION.MINOR));
}
this.processor.events.offer(new Yaml.Event(EVT.VERSION_DIRECTIVE, line, null, data));
this.processor.events.add(new Yaml.Event(EVT.VERSION_DIRECTIVE, line, null, data));
}
/**
* register event tag
* @param evtdata the current data event
@ -143,7 +157,7 @@ public class Pluie.Yaml.Scanner
data.set("handle", mi.fetch (MIEVT_TAG.HANDLE));
data.set("suffix", mi.fetch (MIEVT_TAG.SUFFIX));
}
this.processor.events.offer(new Yaml.Event(EVT.TAG, line, null, data));
this.processor.events.add(new Yaml.Event(EVT.TAG, line, null, data));
}
/**
@ -161,7 +175,7 @@ public class Pluie.Yaml.Scanner
data = new HashMap<string, string>();
data.set("error", mi.fetch (MIEVT_ERROR.DATA));
}
this.processor.events.offer(new Yaml.Event(EVT.NONE, line, null, data));
this.processor.events.add(new Yaml.Event(EVT.NONE, line, null, data));
}
/**
@ -181,7 +195,7 @@ public class Pluie.Yaml.Scanner
data = new HashMap<string, string>();
data.set("data", mi.fetch (MIEVT_SCALAR.DATA));
}
this.processor.events.offer(new Yaml.Event(EVT.SCALAR, line, style, data));
this.processor.events.add(new Yaml.Event(EVT.SCALAR, line, style, data));
}
/**
@ -199,7 +213,7 @@ public class Pluie.Yaml.Scanner
data = new HashMap<string, string>();
data.set("id", mi.fetch (MIEVT_ANCHOR.ID));
}
this.processor.events.offer(new Yaml.Event(EVT.ANCHOR, line, null, data));
this.processor.events.add(new Yaml.Event(EVT.ANCHOR, line, null, data));
}
/**
@ -217,11 +231,11 @@ public class Pluie.Yaml.Scanner
data = new HashMap<string, string>();
data.set("id", mi.fetch (MIEVT_ANCHOR.ID));
}
this.processor.events.offer(new Yaml.Event(EVT.ALIAS, line, null, data));
this.processor.events.add(new Yaml.Event(EVT.ALIAS, line, null, data));
}
/**
* parse specifiyed line
* scan specifiyed line
* @param data the current line
*/
private void scan_event (string? data = null)
@ -257,7 +271,7 @@ public class Pluie.Yaml.Scanner
this.register_event_error(evtdata, line);
break;
default :
this.processor.events.offer(new Yaml.Event((Yaml.EVT)type, line, null, null));
this.processor.events.add(new Yaml.Event((Yaml.EVT)type, line, null, null));
break;
}
}

View File

@ -156,23 +156,12 @@ namespace Pluie
/**
* enum MatchInfo keys of Yaml.Mode.find method related to mode FIND_MODE.SQUARE_BRACKETS of Yaml.Node
*/
internal enum FIND_COLLECTION
{
PATH,
OPEN,
KEY,
CLOSE;
}
internal enum FIND_COLLECTION { PATH, OPEN, KEY, CLOSE; }
/**
* enum MatchInfo keys of Yaml.Node.find method related to mode FIND_MODE.DOT of Yaml.Node
*/
internal enum FIND_DOT
{
PATH,
KEY,
SEQUENCE;
}
internal enum FIND_DOT { PATH, KEY, SEQUENCE; }
/**
* enum possible type of Yaml.Node