diff --git a/src/index.js b/src/index.js index 4e9e65b..6eca734 100644 --- a/src/index.js +++ b/src/index.js @@ -880,6 +880,12 @@ function peg$parse(input, options) { s2 = peg$parseDict(); if (s2 === peg$FAILED) { s2 = peg$parseAssignment(); + if (s2 === peg$FAILED) { + s2 = peg$parseMultylineComment(); + if (s2 === peg$FAILED) { + s2 = peg$parseLineComment(); + } + } } } } @@ -910,6 +916,12 @@ function peg$parse(input, options) { s2 = peg$parseDict(); if (s2 === peg$FAILED) { s2 = peg$parseAssignment(); + if (s2 === peg$FAILED) { + s2 = peg$parseMultylineComment(); + if (s2 === peg$FAILED) { + s2 = peg$parseLineComment(); + } + } } } } diff --git a/src/pegjs/heta.pegjs b/src/pegjs/heta.pegjs index e31d8c9..8796b1a 100644 --- a/src/pegjs/heta.pegjs +++ b/src/pegjs/heta.pegjs @@ -29,7 +29,7 @@ MultylineComment return null; } -BaseStruct = fullLine: (Space/Break/Note/Id/Index/Action/Type/Title/Dict/Assignment)* EndSign +BaseStruct = fullLine: (Space/Break/Note/Id/Index/Action/Type/Title/Dict/Assignment/MultylineComment/LineComment)* EndSign { let res = Object.assign({}, ...fullLine); return res; diff --git a/test/parse/input/notes.heta b/test/parse/input/notes.heta index 58b1d47..3b62c9a 100644 --- a/test/parse/input/notes.heta +++ b/test/parse/input/notes.heta @@ -11,3 +11,11 @@ This is very long text. This is very long text. This is very long text. This is This is very long text. ''' S4 @species {compartment: comp1}; + +'''Notes with trailing comment''' +/* This is comment */ +k1 @Const = 1.1; + +'''Notes with trailing comment''' +// This is comment +k1 @Const = 1.1; \ No newline at end of file diff --git a/test/parse/output/notes.json b/test/parse/output/notes.json index 278f74e..938fbc5 100644 --- a/test/parse/output/notes.json +++ b/test/parse/output/notes.json @@ -18,5 +18,19 @@ "class": "Species", "compartment": "comp1", "notes": "\nThis is very long text. This is very long text's.\nThis is very long text. This is very long text.\nThis is very long text. This is very long text. This is very long text. This is very long text.\nThis is very long text.\n" + }, + { + "id": "k1", + "action": "upsert", + "class": "Const", + "notes": "Notes with trailing comment", + "num": 1.1 + }, + { + "id": "k1", + "action": "upsert", + "class": "Const", + "notes": "Notes with trailing comment", + "num": 1.1 } ]