Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

59
LINES

< > BotCompany Repo | #1002688 // snlParse

JavaX fragment (include)

/*
Binding levels (well...):
0 = lowest
1 = arrows (> lowest)
2 = arrowsr (> arrows)
3 = word (> arrows)
4 = juxta, idword, subword (> word)
*/


static S snlParse_rules = [[
  // highest (strongest binding) level 
  <extidentifier> = idword
  <int> = subword
  <quoted> = subword
  // <ucid> = subword
  
  // random symbols we'd want to use
  // (they don't parse if not listed here)
  ? = symbol
  ! = symbol
  : = symbol
  * = symbol
  "=" = symbol
  + = symbol
  , = symbol
  . = symbol
  <symbol> = idword
  
  <subword> = word
  <idword> = word
  
  // juxtaposition on highest level
  <word> <word> = juxta
  <juxta> = word
  
  // bracketing takes us to highest level
  [ <lowest> ] = square
  ( <lowest> ) = round
  
  <square> = subword
  <round> = subword
  
  // < is intermediate
  <word> = arrowsr
  <word> > <arrowsr> = realarrowr
  <realarrowr> = arrowsr
  
  <arrowsr> < <arrows> = realarrow
  <realarrow> = arrows
  <arrowsr> = arrows
  
  = lowest // allow empty here
  <arrows> = lowest
]];

static Explain snlParse(S input) {
  ret explainFull(snlTok(input), snlParse_rules, "lowest");
}

Author comment

Began life as a copy of #1002683

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1002688
Snippet name: snlParse
Eternal ID of this version: #1002688/1
Text MD5: a805797607a5ebd388a912dd1017fd0e
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-02-25 20:25:30
Source code size: 1169 bytes / 59 lines
Pitched / IR pitched: No / No
Views / Downloads: 597 / 1147
Referenced in: [show references]