Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
P parabix-devel
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 9
    • Issues 9
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge requests 2
    • Merge requests 2
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • cameron
  • parabix-devel
  • Wiki
  • Bracket Matching

Bracket Matching · Changes

Page history
Update Bracket Matching authored Feb 13, 2022 by lperesde's avatar lperesde
Show whitespace changes
Inline Side-by-side
Showing with 39 additions and 1 deletion
+39 -1
  • Bracket-Matching.md Bracket-Matching.md +39 -1
  • No files found.
Bracket-Matching.md
View page @ 4931b6fc
...@@ -116,6 +116,44 @@ after any value or Comma. ...@@ -116,6 +116,44 @@ after any value or Comma.
errAfterLBrak = ScanTo(Advance(arrayStart, 1), anyToken) & ~ (nested | valueToken | RBrak) errAfterLBrak = ScanTo(Advance(arrayStart, 1), anyToken) & ~ (nested | valueToken | RBrak)
``` ```
### Validating objects
Assume we have two bit streams for tokens: `valueToken` (explained above) and `anyToken`, a bit stream marking the end position of any legal or illegal token. Assume also that `LBrace`, `RBrace`, `DQuote`, `Colon` and `Comma` are streams marking the position of JSON `{`, `}`, `"`, `:` and `,` tokens respectively.
```
str = valueToken & DQuote
valueTokenMinusStr = valueToken ^ str
atDepth = bnc.EQ(ND, d)
nested = bnc.UGT(ND, d)
objStart = atDepth & LBrace
objEnd = ScanThru(objStart, nested | (atDepth & ~ (RBrak | RBrace)))
objAtEnd = objEnd & RBrak
objSpan = ExclusiveSpan(objStart, objEnd)
// Now validate that every value or nested item is followed
// either by a comma or a the end RBrace.
afterNested = Advance(nested & objSpan, 1) & atDepth
// process all values that are not strings
afterTokenMinusStr = Advance(valueTokenMinusStr & objSpan, 1)
tokenNextMinusStr = ScanThru(afterNested | afterTokenMinusStr, whitespace)
errAfterValueMinusStr = tokenNextMinusStr &~(Comma | RBrace)
// process strings as both key and value
afterTokenStr = Advance(str & objSpan, 1)
tokenNextStr = ScanThru(afterNested | afterTokenStr, whitespace)
errAfterValueStr = tokenNextStr &~(Comma | RBrace | Colon)
// join errors
errAfterValue = errAfterValueMinusStr | errAfterValueStr
//
// Every Comma must be followed by a value
errAfterComma = ScanTo(Advance(Comma & arraySpan, 1), anyToken) & ~ (nested | valueToken)
// After the LBrak we must have either a value or an RBrak.
errAfterLBrak = ScanTo(Advance(arrayStart, 1), anyToken) & ~ (nested | valueToken | RBrak)
```
# CFG Kernel (_note: this doc isn't ready_) # CFG Kernel (_note: this doc isn't ready_)
The CFG kernel is a Parabix kernel (to be implemented) that can compute a context-free grammars given a set of rules with its own syntax (close to EBNF), a BixNum representing the nesting depth of its tokens (see NestingDepth kernel), and a StreamSet representing all valid markers. The CFG kernel is a Parabix kernel (to be implemented) that can compute a context-free grammars given a set of rules with its own syntax (close to EBNF), a BixNum representing the nesting depth of its tokens (see NestingDepth kernel), and a StreamSet representing all valid markers.
......
Clone repository
  • Bracket Matching
  • CSV Validation
  • CSVediting
  • CSVparsing
  • Character Code Compilers
  • KernelLibrary
  • Pablo
  • ParabixTransform
  • Parallel Deletion
  • Parallel Hashing
  • Performance Testing Script
  • Shuffle Pattern Library
  • StaticCCC
  • String Insertion
  • UCD: Unicode Property Database and Compilers
View All Pages